9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-22 16:29:16 +00:00

Updated Upstream (Paper 1.21.3)

Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@2ef589c okaaay let's go
PaperMC/Paper@d0028b7 you saw nothing
PaperMC/Paper@e080b20 Bundles are no longer experimental (thanks lynx)
PaperMC/Paper@d280061 First batch of server patches
PaperMC/Paper@3585434 first 100!
PaperMC/Paper@6b27267 oops
PaperMC/Paper@152e82c Some work
PaperMC/Paper@9e92fed More work?
PaperMC/Paper@f1649d7 Work it
PaperMC/Paper@9d63c81 Work work work
PaperMC/Paper@dc5af48 Breakpoint before projectile mess
PaperMC/Paper@7c04a31 Update projectile launch to 1.21.2
PaperMC/Paper@a400929 242
PaperMC/Paper@8851d25 Fluid Flowing ifLoaded patch
PaperMC/Paper@f677393 Skip Improve-exact-choice-recipe-ingredients for now
PaperMC/Paper@5e262c1 298
PaperMC/Paper@aa37f72 Patches
PaperMC/Paper@af125d2 Patch
PaperMC/Paper@6bfc6db Patch
PaperMC/Paper@09b625e 400
PaperMC/Paper@1f8b537 440
PaperMC/Paper@f5177aa Some more work
PaperMC/Paper@2810f50 503
PaperMC/Paper@0bb4d1d 553
PaperMC/Paper@4db2503 Work work work work
PaperMC/Paper@cbf6416 A bunch of patches
PaperMC/Paper@6456b5d A bunch more 637
PaperMC/Paper@cb79de8 moooore
PaperMC/Paper@1dc1425 MOOOOORE
PaperMC/Paper@d52e2d2 MOOOOOOOORE
PaperMC/Paper@4baf9ab MOOOOOOOOOOORE
PaperMC/Paper@dd87f9f fix gruesome copyright violation
PaperMC/Paper@5a6011c MOOOOOOOOOOOOOORE
PaperMC/Paper@5d19e2b good luck americans
PaperMC/Paper@457d035 Patches, patches, patches
PaperMC/Paper@80de05f Patch me this, patch me that
PaperMC/Paper@26f7b4c Patch
PaperMC/Paper@89bf081 Patch
PaperMC/Paper@7d4cce9 Patch
PaperMC/Paper@b237528 Readd wrongly removed diff
PaperMC/Paper@fc05430 963
PaperMC/Paper@9047541 Upstream update
PaperMC/Paper@d67e55d Checkpoint
PaperMC/Paper@fe142cd Anti Xray
PaperMC/Paper@35e01d7 Update work 989
PaperMC/Paper@7616ebc 1000
PaperMC/Paper@6a31574 1020
PaperMC/Paper@227caac Wrong attempt at Tag lifecycle
PaperMC/Paper@afbb0d8 1037
PaperMC/Paper@b06e0b0 Work on compile errors
PaperMC/Paper@9c83387 Compile issues 1
PaperMC/Paper@0f011a3 Some more compile issues
PaperMC/Paper@6fb86bb Compiler issues v2
PaperMC/Paper@918ca96 Compiler issues v3
PaperMC/Paper@bb124f4 Compiler issues v4
PaperMC/Paper@0a8fd78 Compiler issue v5
PaperMC/Paper@e19f484 Test compile fixes
PaperMC/Paper@3518974 fix some issues
PaperMC/Paper@6df21e6 Start Moonrise update
PaperMC/Paper@47258a7 Move common diffs to MCUtils
PaperMC/Paper@ecf4d97 Begin fixing issues
PaperMC/Paper@8e569ba Merge patches
PaperMC/Paper@3b31621 Implement config hooks in PaperHooks
PaperMC/Paper@e9c58f5 Implement chunk tick iteration optimisations
PaperMC/Paper@2a95ad1 Implement explosion optimisations
PaperMC/Paper@16d2c9d Implement Starlight
PaperMC/Paper@3d7b570 Implement chunk system
PaperMC/Paper@1d341df Fix some compile errors from patches
PaperMC/Paper@6daedd7 Prepare rebase
PaperMC/Paper@75e3409 Complete rebase, start review
PaperMC/Paper@f1a11a6 Finish mixin diff review
PaperMC/Paper@a911f4a Prepare rebase
PaperMC/Paper@35ef293 Finish rebase
PaperMC/Paper@9ecf77e Fix compile issues
PaperMC/Paper@62e3bcd Review patch-to-patch diff
PaperMC/Paper@b711764 Rebase fixups
PaperMC/Paper@2e76d3f Specify mainCapabilityAttribute for paper-api
PaperMC/Paper@e4efb59 fix compile issues
PaperMC/Paper@683ce20 Fix Anti-Xray using wrong data in chunk deserialize
PaperMC/Paper@e92607c Fix MSPT command
PaperMC/Paper@dcd81a8 Fix crafting (and server icon)
PaperMC/Paper@61136fe Add max minecarft speed gamerule config
PaperMC/Paper@ba1ee87 Revert "Add max minecarft speed gamerule config"
PaperMC/Paper@cf03bed Add startup flag to disable gamerule limits
PaperMC/Paper@be2edea Fix boats/minecarts not dropping when destroyed
PaperMC/Paper@b14d336 Apply watchdoge patches
PaperMC/Paper@2946dbb Update WorldServer#serverlevelData mapping
PaperMC/Paper@98af0e0 update generator
PaperMC/Paper@20507b4 Apply more patches
PaperMC/Paper@7162ff0 fix item meta
PaperMC/Paper@7d67d3f fix DamageTypeTags init
PaperMC/Paper@0971875 re-add improve perf of mass crafts
PaperMC/Paper@bcf52fe Delete some old patches
PaperMC/Paper@348c855 Readd last API patch (with TODO)
PaperMC/Paper@b630564 More patches
PaperMC/Paper@3cb16c9 Add back per player mob spawning
PaperMC/Paper@fe7b741 Another one
PaperMC/Paper@12ed021 Update material tags and entity effect
PaperMC/Paper@02bca1e Remove timings impl
PaperMC/Paper@4d87302 Fix NPE and StackOverflowError for dispensers
PaperMC/Paper@f8f230a Remove unnecessary AT
PaperMC/Paper@29bf7be Fix unused parameter in PlayerList#remove
PaperMC/Paper@9e35192 Execute spark tasks during tick sleep (#11525)
PaperMC/Paper@e35f199 Use declaration order for state holder property iteration
PaperMC/Paper@6288adb Remove leftover missed timings calls (#11527)
PaperMC/Paper@99b1bf9 Use new ClientboundPlayerRotationPacket for setting player rotation
PaperMC/Paper@40211a0 Update Gradle wrapper to 8.10.2
PaperMC/Paper@49eae0d remove some leftovers
PaperMC/Paper@d576cfc cleanup bugfix patch
PaperMC/Paper@1196ab5 Avoid issues with certain tasks not processing during sleep (#11526)
PaperMC/Paper@fe2f3d4 Fix portal exit resulting in bad teleport transition
PaperMC/Paper@9f1fa0b Fix item gravity on inactive items, remove dumb active skipping
PaperMC/Paper@1a1d0cf Use target pitch in teleport (generally the same thing)
PaperMC/Paper@8ba3073 fix "is_freezing" damage type tag
PaperMC/Paper@1523212 don't resend effects when PlayerItemConsumeEvent is cancelled
PaperMC/Paper@1330880 Add Friction API to minecarts
PaperMC/Paper@580a610 Allow using old ender pearl behavior & apply ender pearl exploit patch (#11524)
PaperMC/Paper@40a960d Rebuild patches
This commit is contained in:
Samsuik
2024-10-30 23:59:24 +00:00
parent 56429ad767
commit 133fe330ae
90 changed files with 1638 additions and 1525 deletions

View File

@@ -22,3 +22,4 @@ minecraft net.minecraft.world.item.Item
minecraft net.minecraft.world.item.SwordItem minecraft net.minecraft.world.item.SwordItem
minecraft net.minecraft.world.item.DiggerItem minecraft net.minecraft.world.item.DiggerItem
minecraft net.minecraft.world.food.Foods minecraft net.minecraft.world.food.Foods
minecraft net.minecraft.world.item.Items

View File

@@ -2,7 +2,7 @@ import io.papermc.paperweight.util.constants.PAPERCLIP_CONFIG
plugins { plugins {
java java
id("io.papermc.paperweight.patcher") version "1.7.1" id("io.papermc.paperweight.patcher") version "1.7.4"
} }
repositories { repositories {

View File

@@ -1,8 +1,8 @@
group=me.samsuik.sakura group=me.samsuik.sakura
version=1.21.1-R0.1-SNAPSHOT version=1.21.3-R0.1-SNAPSHOT
mcVersion=1.21.1 mcVersion=1.21.3
paperRef=d348cb88a9fe8d19e46102c8b9febe18f746d46b paperRef=40a960db45f45f381328a60695e933615475aea8
org.gradle.jvmargs=-Xmx2G org.gradle.jvmargs=-Xmx2G
org.gradle.vfs.watch=false org.gradle.vfs.watch=false

View File

@@ -209,10 +209,10 @@ index 0000000000000000000000000000000000000000..3df11f07ce533b8b911ec423be850374
+ +
+} +}
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 7c56182acaf827f4b1a986a61cea8e9960604c98..4c2e82a6421722d9a990ff4a216cedc159c7e579 100644 index 95f0b3186e313c7fbd5c8531d52b82a69e525f94..a1d6e58d466b94d65c830a7e50b9a5eae76138aa 100644
--- a/src/main/java/org/bukkit/entity/Player.java --- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java
@@ -59,6 +59,15 @@ import org.jetbrains.annotations.Nullable; @@ -60,6 +60,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, net.kyori.adventure.bossbar.BossBarViewer, com.destroystokyo.paper.network.NetworkClient { // Paper

View File

@@ -27,10 +27,10 @@ index ee3057c7969956b9c552ac5ceb2f5e38a30e9cdf..58f220a3f48a8cc1a25249d4a56cf356
public boolean equals(Object o) { 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 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 new file mode 100644
index 0000000000000000000000000000000000000000..b27a757b6d3d43df589947fa65857011da920529 index 0000000000000000000000000000000000000000..51aa1c9495170b51182cf76e9b6526d6e9c5287f
--- /dev/null --- /dev/null
+++ b/src/main/java/me/samsuik/sakura/physics/PhysicsVersion.java +++ b/src/main/java/me/samsuik/sakura/physics/PhysicsVersion.java
@@ -0,0 +1,94 @@ @@ -0,0 +1,95 @@
+package me.samsuik.sakura.physics; +package me.samsuik.sakura.physics;
+ +
+public enum PhysicsVersion { +public enum PhysicsVersion {
@@ -50,6 +50,7 @@ index 0000000000000000000000000000000000000000..b27a757b6d3d43df589947fa65857011
+ v1_18_2("1.18.2", 1_18_2), + v1_18_2("1.18.2", 1_18_2),
+ v1_19_3("1.19.3", 1_19_3), + v1_19_3("1.19.3", 1_19_3),
+ v1_20("1.20", 1_20_0), + v1_20("1.20", 1_20_0),
+ v1_21_2("1.21.2", 1_21_2),
+ // refers to the latest mechanic version + // refers to the latest mechanic version
+ LATEST("latest", 9_99_9); + LATEST("latest", 9_99_9);
+ +

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Entity tracking range modifier
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 4c2e82a6421722d9a990ff4a216cedc159c7e579..489ad34e24c8b65d8ac7623d38707fb768d3cac1 100644 index a1d6e58d466b94d65c830a7e50b9a5eae76138aa..a4a497d20b17fa89106681c00918b08ebca7e87f 100644
--- a/src/main/java/org/bukkit/entity/Player.java --- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java
@@ -68,6 +68,12 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM @@ -69,6 +69,12 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
me.samsuik.sakura.player.visibility.Visibility getVisibility(); me.samsuik.sakura.player.visibility.Visibility getVisibility();
// Sakura end // Sakura end

View File

@@ -27,9 +27,18 @@ index 87e5f614ba988547a827486740db217e28585773..0375c9eb296ba7e8ed64e8d00dbc13a5
} else { } else {
this.verifyWorldConfigVersion(contextMap, worldNode); this.verifyWorldConfigVersion(contextMap, worldNode);
diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
index 1029b6de6f36b08bf634b4056ef5701383f6f258..f8c4b602756eeb2f3daab910e1d75bbb962880d2 100644 index 1029b6de6f36b08bf634b4056ef5701383f6f258..4b4087c316460c8ae262b62746430f521a9cc1a2 100644
--- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java --- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
@@ -165,7 +165,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
.defaultOptions(PaperConfigurations::defaultOptions);
}
- private static ConfigurationOptions defaultOptions(ConfigurationOptions options) {
+ public static ConfigurationOptions defaultOptions(ConfigurationOptions options) { // Sakura - sakura configuration files
return options.serializers(builder -> builder
.register(MapSerializer.TYPE, new MapSerializer(false))
.register(new EnumValueSerializer())
@@ -459,7 +459,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor @@ -459,7 +459,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
} }
@@ -251,7 +260,7 @@ index 0000000000000000000000000000000000000000..c41f188fdaf510a127771b1782e95705
+} +}
diff --git a/src/main/java/me/samsuik/sakura/configuration/GlobalConfiguration.java b/src/main/java/me/samsuik/sakura/configuration/GlobalConfiguration.java diff --git a/src/main/java/me/samsuik/sakura/configuration/GlobalConfiguration.java b/src/main/java/me/samsuik/sakura/configuration/GlobalConfiguration.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..ab790630fe4a95ac0e7139e5d41fd8df3393e738 index 0000000000000000000000000000000000000000..1b49023726fc80231ba952c555923228130a2bdb
--- /dev/null --- /dev/null
+++ b/src/main/java/me/samsuik/sakura/configuration/GlobalConfiguration.java +++ b/src/main/java/me/samsuik/sakura/configuration/GlobalConfiguration.java
@@ -0,0 +1,62 @@ @@ -0,0 +1,62 @@
@@ -267,7 +276,7 @@ index 0000000000000000000000000000000000000000..ab790630fe4a95ac0e7139e5d41fd8df
+import org.spongepowered.configurate.objectmapping.meta.Setting; +import org.spongepowered.configurate.objectmapping.meta.Setting;
+ +
+@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic", "RedundantSuppression"}) +@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic", "RedundantSuppression"})
+public class GlobalConfiguration extends ConfigurationPart { +public final class GlobalConfiguration extends ConfigurationPart {
+ +
+ private static final Logger LOGGER = LogUtils.getClassLogger(); + private static final Logger LOGGER = LogUtils.getClassLogger();
+ static final int CURRENT_VERSION = 3;// (when you change the version, change the comment, so it conflicts on rebases): rename filter bad nbt from spawn eggs + static final int CURRENT_VERSION = 3;// (when you change the version, change the comment, so it conflicts on rebases): rename filter bad nbt from spawn eggs
@@ -319,10 +328,10 @@ index 0000000000000000000000000000000000000000..ab790630fe4a95ac0e7139e5d41fd8df
+} +}
diff --git a/src/main/java/me/samsuik/sakura/configuration/SakuraConfigurations.java b/src/main/java/me/samsuik/sakura/configuration/SakuraConfigurations.java 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 new file mode 100644
index 0000000000000000000000000000000000000000..94dd734ca4049354f925af1736bda57cd9be43dd index 0000000000000000000000000000000000000000..9460afc669594ddb53b097ae105abb29da3a7e10
--- /dev/null --- /dev/null
+++ b/src/main/java/me/samsuik/sakura/configuration/SakuraConfigurations.java +++ b/src/main/java/me/samsuik/sakura/configuration/SakuraConfigurations.java
@@ -0,0 +1,270 @@ @@ -0,0 +1,241 @@
+package me.samsuik.sakura.configuration; +package me.samsuik.sakura.configuration;
+ +
+import com.google.common.collect.Table; +import com.google.common.collect.Table;
@@ -346,6 +355,7 @@ index 0000000000000000000000000000000000000000..94dd734ca4049354f925af1736bda57c
+import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap; +import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
+import it.unimi.dsi.fastutil.objects.Reference2LongMap; +import it.unimi.dsi.fastutil.objects.Reference2LongMap;
+import it.unimi.dsi.fastutil.objects.Reference2LongOpenHashMap; +import it.unimi.dsi.fastutil.objects.Reference2LongOpenHashMap;
+import me.samsuik.sakura.configuration.transformation.ConfigurationTransformations;
+import me.samsuik.sakura.configuration.transformation.global.V1_RelocateMessages; +import me.samsuik.sakura.configuration.transformation.global.V1_RelocateMessages;
+import me.samsuik.sakura.configuration.transformation.global.V2_ConvertIconToMaterial; +import me.samsuik.sakura.configuration.transformation.global.V2_ConvertIconToMaterial;
+import me.samsuik.sakura.configuration.transformation.world.*; +import me.samsuik.sakura.configuration.transformation.world.*;
@@ -359,6 +369,7 @@ index 0000000000000000000000000000000000000000..94dd734ca4049354f925af1736bda57c
+import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
+import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable;
+import org.jspecify.annotations.NullMarked;
+import org.slf4j.Logger; +import org.slf4j.Logger;
+import org.spongepowered.configurate.ConfigurateException; +import org.spongepowered.configurate.ConfigurateException;
+import org.spongepowered.configurate.ConfigurationNode; +import org.spongepowered.configurate.ConfigurationNode;
@@ -378,8 +389,9 @@ index 0000000000000000000000000000000000000000..94dd734ca4049354f925af1736bda57c
+ +
+import static io.leangen.geantyref.GenericTypeReflector.erase; +import static io.leangen.geantyref.GenericTypeReflector.erase;
+ +
+@NullMarked
+@SuppressWarnings("Convert2Diamond") +@SuppressWarnings("Convert2Diamond")
+public class SakuraConfigurations extends Configurations<GlobalConfiguration, WorldConfiguration> { +public final class SakuraConfigurations extends Configurations<GlobalConfiguration, WorldConfiguration> {
+ +
+ private static final Logger LOGGER = LogUtils.getClassLogger(); + private static final Logger LOGGER = LogUtils.getClassLogger();
+ static final String GLOBAL_CONFIG_FILE_NAME = "sakura-global.yml"; + static final String GLOBAL_CONFIG_FILE_NAME = "sakura-global.yml";
@@ -421,15 +433,7 @@ index 0000000000000000000000000000000000000000..94dd734ca4049354f925af1736bda57c
+ @Override + @Override
+ protected YamlConfigurationLoader.Builder createLoaderBuilder() { + protected YamlConfigurationLoader.Builder createLoaderBuilder() {
+ return super.createLoaderBuilder() + return super.createLoaderBuilder()
+ .defaultOptions(SakuraConfigurations::defaultOptions); + .defaultOptions(PaperConfigurations::defaultOptions);
+ }
+
+ private static ConfigurationOptions defaultOptions(ConfigurationOptions options) {
+ return options.serializers(builder -> builder
+ .register(MapSerializer.TYPE, new MapSerializer(false))
+ .register(new EnumValueSerializer())
+ .register(new ComponentSerializer())
+ );
+ } + }
+ +
+ @Override + @Override
@@ -452,7 +456,6 @@ index 0000000000000000000000000000000000000000..94dd734ca4049354f925af1736bda57c
+ .header(GLOBAL_HEADER) + .header(GLOBAL_HEADER)
+ .serializers(builder -> builder + .serializers(builder -> builder
+ .register(new PacketClassSerializer()) + .register(new PacketClassSerializer())
+ .register(IntOr.Default.SERIALIZER)
+ ); + );
+ } + }
+ +
@@ -478,9 +481,7 @@ index 0000000000000000000000000000000000000000..94dd734ca4049354f925af1736bda57c
+ } + }
+ +
+ private static WorldConfiguration createWorldConfigInstance(ContextMap contextMap) { + private static WorldConfiguration createWorldConfigInstance(ContextMap contextMap) {
+ return new WorldConfiguration( + return new WorldConfiguration(contextMap.require(Configurations.WORLD_KEY));
+ contextMap.require(Configurations.WORLD_KEY)
+ );
+ } + }
+ +
+ @Override + @Override
@@ -494,13 +495,6 @@ index 0000000000000000000000000000000000000000..94dd734ca4049354f925af1736bda57c
+ .register(new TypeToken<Reference2LongMap<?>>() {}, new FastutilMapSerializer.SomethingToPrimitive<Reference2LongMap<?>>(Reference2LongOpenHashMap::new, Long.TYPE)) + .register(new TypeToken<Reference2LongMap<?>>() {}, new FastutilMapSerializer.SomethingToPrimitive<Reference2LongMap<?>>(Reference2LongOpenHashMap::new, Long.TYPE))
+ .register(new TypeToken<Table<?, ?, ?>>() {}, new TableSerializer()) + .register(new TypeToken<Table<?, ?, ?>>() {}, new TableSerializer())
+ .register(StringRepresentableSerializer::isValidFor, new StringRepresentableSerializer()) + .register(StringRepresentableSerializer::isValidFor, new StringRepresentableSerializer())
+ .register(IntOr.Default.SERIALIZER)
+ .register(IntOr.Disabled.SERIALIZER)
+ .register(DoubleOr.Default.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<>(new TypeToken<EntityType<?>>() {}, access, Registries.ENTITY_TYPE, true))
+ .register(new RegistryValueSerializer<>(Item.class, access, Registries.ITEM, true)) + .register(new RegistryValueSerializer<>(Item.class, access, Registries.ITEM, true))
+ .register(new RegistryValueSerializer<>(Block.class, access, Registries.BLOCK, true)) + .register(new RegistryValueSerializer<>(Block.class, access, Registries.BLOCK, true))
@@ -511,26 +505,12 @@ index 0000000000000000000000000000000000000000..94dd734ca4049354f925af1736bda57c
+ +
+ @Override + @Override
+ protected void applyWorldConfigTransformations(final ContextMap contextMap, final ConfigurationNode node, final @Nullable ConfigurationNode defaultsNode) throws ConfigurateException { + protected void applyWorldConfigTransformations(final ContextMap contextMap, final ConfigurationNode node, final @Nullable ConfigurationNode defaultsNode) throws ConfigurateException {
+ final ConfigurationTransformation.VersionedBuilder versionedBuilder = Transformations.versionedBuilder(); + ConfigurationTransformations.worldTransformations(node);
+ V2_VerticalKnockbackUseDefault.apply(versionedBuilder);
+ V3_RenameKnockback.apply(versionedBuilder);
+ V4_RenameNonStrictMergeLevel.apply(versionedBuilder);
+ V5_CombineLoadChunksOptions.apply(versionedBuilder);
+ V6_FixIncorrectExtraKnockback.apply(versionedBuilder);
+ // ADD FUTURE VERSIONED TRANSFORMS TO versionedBuilder HERE
+ versionedBuilder.build().apply(node);
+ } + }
+ +
+ @Override + @Override
+ protected void applyGlobalConfigTransformations(final ConfigurationNode node) throws ConfigurateException { + protected void applyGlobalConfigTransformations(final ConfigurationNode node) throws ConfigurateException {
+ final ConfigurationTransformation.Builder builder = ConfigurationTransformation.builder(); + ConfigurationTransformations.globalTransformations(node);
+ builder.addAction(NodePath.path("cannons"), TransformAction.remove());
+ builder.build().apply(node);
+
+ final ConfigurationTransformation.VersionedBuilder versionedBuilder = Transformations.versionedBuilder();
+ V1_RelocateMessages.apply(versionedBuilder);
+ V2_ConvertIconToMaterial.apply(versionedBuilder);
+ versionedBuilder.build().apply(node);
+ } + }
+ +
+ @Override + @Override
@@ -566,7 +546,7 @@ index 0000000000000000000000000000000000000000..94dd734ca4049354f925af1736bda57c
+ this.createWorldConfig(createWorldContextMap(level), reloader(this.worldConfigClass, level.sakuraConfig())); + this.createWorldConfig(createWorldContextMap(level), reloader(this.worldConfigClass, level.sakuraConfig()));
+ } + }
+ } catch (Exception ex) { + } catch (Exception ex) {
+ throw new RuntimeException("Could not reload paper configuration files", ex); + throw new RuntimeException("Could not reload sakura configuration files", ex);
+ } + }
+ } + }
+ +
@@ -595,7 +575,7 @@ index 0000000000000000000000000000000000000000..94dd734ca4049354f925af1736bda57c
+} +}
diff --git a/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java 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 new file mode 100644
index 0000000000000000000000000000000000000000..7c579c28294452e107aa32eae3d07fde49087436 index 0000000000000000000000000000000000000000..3ccd52a58996b60ec860fb50a509b92739f45b28
--- /dev/null --- /dev/null
+++ b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java +++ b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
@@ -0,0 +1,236 @@ @@ -0,0 +1,236 @@
@@ -627,7 +607,7 @@ index 0000000000000000000000000000000000000000..7c579c28294452e107aa32eae3d07fde
+import java.util.Map; +import java.util.Map;
+ +
+@SuppressWarnings({"FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic", "RedundantSuppression"}) +@SuppressWarnings({"FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic", "RedundantSuppression"})
+public class WorldConfiguration extends ConfigurationPart { +public final class WorldConfiguration extends ConfigurationPart {
+ +
+ private static final Logger LOGGER = LogUtils.getClassLogger(); + private static final Logger LOGGER = LogUtils.getClassLogger();
+ static final int CURRENT_VERSION = 6; // (when you change the version, change the comment, so it conflicts on rebases): rename filter bad nbt from spawn eggs + static final int CURRENT_VERSION = 6; // (when you change the version, change the comment, so it conflicts on rebases): rename filter bad nbt from spawn eggs
@@ -683,7 +663,7 @@ index 0000000000000000000000000000000000000000..7c579c28294452e107aa32eae3d07fde
+ +
+ public boolean isFallingBlockInBounds(FallingBlockEntity entity) { + public boolean isFallingBlockInBounds(FallingBlockEntity entity) {
+ return (!this.preventAgainstBorder || !ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.isCollidingWithBorder(entity.level().getWorldBorder(), entity.getBoundingBox().inflate(0.01))) + return (!this.preventAgainstBorder || !ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.isCollidingWithBorder(entity.level().getWorldBorder(), entity.getBoundingBox().inflate(0.01)))
+ && (!this.preventAtWorldHeight || entity.blockPosition().getY() < entity.level().getMaxBuildHeight() - 1); + && (!this.preventAtWorldHeight || entity.blockPosition().getY() < entity.level().getMaxY() - 1);
+ } + }
+ } + }
+ +
@@ -835,6 +815,58 @@ index 0000000000000000000000000000000000000000..7c579c28294452e107aa32eae3d07fde
+ } + }
+ +
+} +}
diff --git a/src/main/java/me/samsuik/sakura/configuration/transformation/ConfigurationTransformations.java b/src/main/java/me/samsuik/sakura/configuration/transformation/ConfigurationTransformations.java
new file mode 100644
index 0000000000000000000000000000000000000000..154ab96b537efc3505cd85935150ddbe7ca1126f
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/configuration/transformation/ConfigurationTransformations.java
@@ -0,0 +1,46 @@
+package me.samsuik.sakura.configuration.transformation;
+
+import io.papermc.paper.configuration.transformation.Transformations;
+import me.samsuik.sakura.configuration.transformation.global.V1_RelocateMessages;
+import me.samsuik.sakura.configuration.transformation.global.V2_ConvertIconToMaterial;
+import me.samsuik.sakura.configuration.transformation.world.*;
+import org.spongepowered.configurate.ConfigurateException;
+import org.spongepowered.configurate.ConfigurationNode;
+import org.spongepowered.configurate.NodePath;
+import org.spongepowered.configurate.transformation.ConfigurationTransformation;
+import org.spongepowered.configurate.transformation.TransformAction;
+
+import java.util.List;
+
+public final class ConfigurationTransformations {
+ private static final List<NodePath> REMOVED_GLOBAL_PATHS = List.of(
+ NodePath.path("cannons")
+ );
+
+ public static void worldTransformations(final ConfigurationNode node) throws ConfigurateException {
+ final ConfigurationTransformation.VersionedBuilder versionedBuilder = Transformations.versionedBuilder();
+ V2_VerticalKnockbackUseDefault.apply(versionedBuilder);
+ V3_RenameKnockback.apply(versionedBuilder);
+ V4_RenameNonStrictMergeLevel.apply(versionedBuilder);
+ V5_CombineLoadChunksOptions.apply(versionedBuilder);
+ V6_FixIncorrectExtraKnockback.apply(versionedBuilder);
+ // ADD FUTURE VERSIONED TRANSFORMS TO versionedBuilder HERE
+ versionedBuilder.build().apply(node);
+ }
+
+ public static void globalTransformations(final ConfigurationNode node) throws ConfigurateException {
+ final ConfigurationTransformation.Builder builder = ConfigurationTransformation.builder();
+ for (final NodePath path : REMOVED_GLOBAL_PATHS) {
+ builder.addAction(path, TransformAction.remove());
+ }
+ builder.build().apply(node);
+
+ final ConfigurationTransformation.VersionedBuilder versionedBuilder = Transformations.versionedBuilder();
+ V1_RelocateMessages.apply(versionedBuilder);
+ V2_ConvertIconToMaterial.apply(versionedBuilder);
+ // ADD FUTURE VERSIONED TRANSFORMS TO versionedBuilder HERE
+ versionedBuilder.build().apply(node);
+ }
+
+ private ConfigurationTransformations() {}
+}
diff --git a/src/main/java/me/samsuik/sakura/configuration/transformation/global/V1_RelocateMessages.java b/src/main/java/me/samsuik/sakura/configuration/transformation/global/V1_RelocateMessages.java diff --git a/src/main/java/me/samsuik/sakura/configuration/transformation/global/V1_RelocateMessages.java b/src/main/java/me/samsuik/sakura/configuration/transformation/global/V1_RelocateMessages.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..6c72577e3fac9324ebe786e8d23969c3082ed618 index 0000000000000000000000000000000000000000..6c72577e3fac9324ebe786e8d23969c3082ed618
@@ -1117,10 +1149,10 @@ index 0000000000000000000000000000000000000000..4024f9738e039ffffd560a07a2210f75
+public record DurableMaterial(int durability, float resistance) { +public record DurableMaterial(int durability, float resistance) {
+} +}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 696d075ca2883f3c37e35f983c4d020e5db89d16..f7a636990d581ad0230317a716d2662ea25480e3 100644 index 7933d6900dac67a24fb5f9378097dbde34be30b1..3a47504876cf718935786d7b858cb6d53bd61ddb 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -317,6 +317,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -327,6 +327,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
public final double[] recentTps = new double[ 3 ]; public final double[] recentTps = new double[ 3 ];
// Spigot end // Spigot end
public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations; // Paper - add paper configuration files public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations; // Paper - add paper configuration files
@@ -1128,7 +1160,7 @@ index 696d075ca2883f3c37e35f983c4d020e5db89d16..f7a636990d581ad0230317a716d2662e
public boolean isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked public boolean isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
public volatile Thread shutdownThread; // Paper public volatile Thread shutdownThread; // Paper
@@ -496,6 +497,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -511,6 +512,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this)); Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
// CraftBukkit end // CraftBukkit end
this.paperConfigurations = services.paperConfigurations(); // Paper - add paper configuration files this.paperConfigurations = services.paperConfigurations(); // Paper - add paper configuration files
@@ -1140,10 +1172,10 @@ index 696d075ca2883f3c37e35f983c4d020e5db89d16..f7a636990d581ad0230317a716d2662e
private void readScoreboard(DimensionDataStorage persistentStateManager) { 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 diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index dd56c8e041116ef3602a9f89c998c8208ab89b51..6cc0386531bea4ed11d9461c6810d7d119b37bf6 100644 index 17a158ff6ce6520b69a5a0032ba4c05449dd0cf8..282a0f91e41a0dcdeb48111a64a83b480efb2acd 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -239,6 +239,11 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -236,6 +236,11 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark
com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now
@@ -1156,23 +1188,23 @@ index dd56c8e041116ef3602a9f89c998c8208ab89b51..6cc0386531bea4ed11d9461c6810d7d1
this.setPvpAllowed(dedicatedserverproperties.pvp); this.setPvpAllowed(dedicatedserverproperties.pvp);
this.setFlightAllowed(dedicatedserverproperties.allowFlight); 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 diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index f9abf63e12ea930275121b470e4e4906cff0fc12..1a0819301e0ce05c60b6cb961202a5c60697f6c1 100644 index 5964d601c05176f48167cc92057a59e52a4da92b..32742470eea2ec86c0fff02aa157bfcc89530ad3 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -503,7 +503,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. @@ -590,7 +590,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
// Holder holder = worlddimension.type(); // CraftBukkit - decompile error
// Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error // Add env and gen to constructor, IWorldDataServer -> WorldDataServer
- 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(), iworlddataserver.getGameRules())), executor); // Paper - create paper world configs; Async-Anti-Xray: Pass executor public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
+ 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(), iworlddataserver.getGameRules())), () -> minecraftserver.sakuraConfigurations.createWorldConfig(me.samsuik.sakura.configuration.SakuraConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), minecraftserver.registryAccess())), executor); // Sakura - sakura configuration files // Paper - create paper world configs; Async-Anti-Xray: Pass executor - super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), 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(), iworlddataserver.getGameRules())), executor); // Paper - create paper world configs; Async-Anti-Xray: Pass executor
+ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), 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(), iworlddataserver.getGameRules())), () -> minecraftserver.sakuraConfigurations.createWorldConfig(me.samsuik.sakura.configuration.SakuraConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), minecraftserver.registryAccess())), executor); // Sakura - sakura configuration files // Paper - create paper world configs; Async-Anti-Xray: Pass executor
this.pvpMode = minecraftserver.isPvpAllowed(); this.pvpMode = minecraftserver.isPvpAllowed();
this.convertable = convertable_conversionsession; this.convertable = convertable_conversionsession;
this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile()); 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 diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 507671476c3d2d92a2fdb05be24443af27d26dcf..48c2d026fd678f7990738a0037780a535f1ac19b 100644 index 022de445bbbb869c38be4972c98dcf1c665539ec..d95292d388efa4c504440347f1e5dfc2b87b8afe 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -171,6 +171,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -172,6 +172,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
return this.paperConfig; return this.paperConfig;
} }
// Paper end - add paper world config // Paper end - add paper world config
@@ -1184,13 +1216,18 @@ index 507671476c3d2d92a2fdb05be24443af27d26dcf..48c2d026fd678f7990738a0037780a53
+ // Sakura end - sakura configuration files + // Sakura end - sakura configuration files
public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray
public final co.aikar.timings.WorldTimingsHandler timings; // Paper public static BlockPos lastPhysicsProblem; // Spigot
@@ -684,9 +690,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -830,7 +836,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
} }
// Paper end - optimise random ticking // Paper end - optimise random ticking
- 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, java.util.concurrent.Executor executor) { // Paper - create paper world config & Anti-Xray - protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, 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, java.util.concurrent.Executor executor) { // Paper - create paper world config & Anti-Xray
+ 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 - sakura configuration files// Paper - create paper world config & Anti-Xray + protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, 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, java.util.function.Supplier<me.samsuik.sakura.configuration.WorldConfiguration> sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura - sakura configuration files // Paper - create paper world config & Anti-Xray
// Paper start - getblock optimisations - cache world height/sections
final DimensionType dimType = holder.value();
this.minY = dimType.minY();
@@ -842,6 +848,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
// Paper end - getblock optimisations - cache world height/sections
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config
+ this.sakuraConfig = sakuraWorldConfigCreator.get(); // Sakura - sakura configuration files + this.sakuraConfig = sakuraWorldConfigCreator.get(); // Sakura - sakura configuration files
@@ -1198,18 +1235,18 @@ index 507671476c3d2d92a2fdb05be24443af27d26dcf..48c2d026fd678f7990738a0037780a53
this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env); 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 diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index c7df339aeb62ee627edaf1bb4c8474b61e357ba6..b8ea9773efb2c701eeed3c56df9965d6a99320b4 100644 index 9f9eefc7346838a9effcda861cecd098092efb0f..2205444180ae615b50a3cbae6bf5fa31504aeff0 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1072,6 +1072,7 @@ public final class CraftServer implements Server { @@ -1074,6 +1074,7 @@ public final class CraftServer implements Server {
org.spigotmc.SpigotConfig.init((File) this.console.options.valueOf("spigot-settings")); // Spigot org.spigotmc.SpigotConfig.init((File) this.console.options.valueOf("spigot-settings")); // Spigot
this.console.paperConfigurations.reloadConfigs(this.console); this.console.paperConfigurations.reloadConfigs(this.console);
+ this.console.sakuraConfigurations.reloadConfigs(this.console); // Sakura - missing comment above :< + this.console.sakuraConfigurations.reloadConfigs(this.console); // Sakura - sakura configuration files; missing comment above :<
for (ServerLevel world : this.console.getAllLevels()) { for (ServerLevel world : this.console.getAllLevels()) {
// world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean))
@@ -1103,6 +1104,7 @@ public final class CraftServer implements Server { @@ -1105,6 +1106,7 @@ public final class CraftServer implements Server {
this.reloadData(); this.reloadData();
org.spigotmc.SpigotConfig.registerCommands(); // Spigot org.spigotmc.SpigotConfig.registerCommands(); // Spigot
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
@@ -1218,7 +1255,7 @@ index c7df339aeb62ee627edaf1bb4c8474b61e357ba6..b8ea9773efb2c701eeed3c56df9965d6
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*"); this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions"); 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 diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index b3ba6bccdbb08af27916f0c611c60b2595b90164..b73c0be9ca17f6f490ddd2a4dc9f9ac8418088b2 100644 index a7524d3853d5b67b6385d2b74832b9267503dfe6..cab99463b969b6414d506c73c71e7e81f39c5541 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java --- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -176,6 +176,14 @@ public class Main { @@ -176,6 +176,14 @@ public class Main {

View File

@@ -227,22 +227,22 @@ index 0000000000000000000000000000000000000000..5b3e2cca7ee16bc6ecfa0f29438fa658
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index f7a636990d581ad0230317a716d2662ea25480e3..f0ba7597de6f1eb025639cbe0f35f51d839fe4c2 100644 index 3a47504876cf718935786d7b858cb6d53bd61ddb..3ef2f8b523b940db18a5d512f21f037fc799f487 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1818,6 +1818,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1886,6 +1886,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.profiler.pop();
this.profiler.pop(); gameprofilerfiller.pop();
worldserver.explosionDensityCache.clear(); // Paper - Optimize explosions gameprofilerfiller.pop();
+ worldserver.localConfig().expire(currentTick); // Sakura - add local config + worldserver.localConfig().expire(currentTick); // Sakura - add local config
} }
this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 48c2d026fd678f7990738a0037780a535f1ac19b..613c402744314644f86b401fa84dbd20ffb108f5 100644 index d95292d388efa4c504440347f1e5dfc2b87b8afe..b5ce268d1b9d8e57a3927c8e0b91746361fb6778 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/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, ca.spottedl @@ -178,6 +178,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
return this.sakuraConfig; return this.sakuraConfig;
} }
// Sakura end - sakura configuration files // Sakura end - sakura configuration files
@@ -254,12 +254,12 @@ index 48c2d026fd678f7990738a0037780a535f1ac19b..613c402744314644f86b401fa84dbd20
+ // Sakura end - add local config + // Sakura end - add local config
public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray
public final co.aikar.timings.WorldTimingsHandler timings; // Paper public static BlockPos lastPhysicsProblem; // Spigot
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 33e4818ba5a90d78d69baad9f6b1be1b1382e9f3..d14c942a4505222c13bf0e7bc15ac4904f3ebbd1 100644 index d41c81158c00931e6b11093cce141f6a3085ba05..6809c9fbc67b40c24d913d28c8dc54f8cc0c9989 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -291,6 +291,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { @@ -295,6 +295,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
} }
// Paper end // Paper end

View File

@@ -251,48 +251,50 @@ index 1a37654aff9a9c86c9f7af10a1cf721371f0c5ec..82644b34a77dc5e5af38260b7b07b3ec
public ClientboundSectionBlocksUpdatePacket(SectionPos sectionPos, ShortSet positions, LevelChunkSection section) { public ClientboundSectionBlocksUpdatePacket(SectionPos sectionPos, ShortSet positions, LevelChunkSection section) {
this.sectionPos = sectionPos; this.sectionPos = sectionPos;
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index af8cb316ac169aa8d98a88765b85bb013b9ba961..76d4b7e9dad6536c100e5940f9f528ba2561e3b8 100644 index 5b3a886c624b36557cbfaccdc3fb05a46a4ba36a..464fc90376075ecc46f7b7731ba5e2c705324e7d 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -172,6 +172,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -179,6 +179,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return null; // Paper - rewrite chunk system this.handleLegacyStructureIndex(pos);
} }
// Paper end // Paper end - rewrite chunk system
+ private final it.unimi.dsi.fastutil.longs.Long2IntMap minimalEntities = new it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap(); // Sakura - visibility api + private final it.unimi.dsi.fastutil.longs.Long2IntMap minimalEntities = new it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap(); // Sakura - visibility api
public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory, int viewDistance, boolean dsync) { public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory, int viewDistance, boolean dsync) {
super(new RegionStorageInfo(session.getLevelId(), world.dimension(), "chunk"), session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync); super(new RegionStorageInfo(session.getLevelId(), world.dimension(), "chunk"), session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync);
@@ -943,6 +944,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -979,6 +980,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
tracker.serverEntity.sendChanges();
} }
((ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerTrackedEntity)tracker).moonrise$clearPlayers();
} }
+ +
+ this.minimalEntities.clear(); // Sakura - visibility api and command + this.minimalEntities.clear(); // Sakura - visibility api and command
} }
// Paper end - optimise entity tracker // Paper end - optimise entity tracker
@@ -1179,6 +1182,29 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1216,6 +1219,31 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} return !this.seenBy.isEmpty();
} }
// Paper end - optimise entity tracker // Paper end - optimise entity tracker
+ // Sakura start - visibility api and command + // Sakura start - visibility api and command
+ private boolean checkEntityVisibility(ServerPlayer player) { + private boolean checkEntityVisibility(final ServerPlayer player) {
+ if (player.visibility.isModified() || !(this.entity.isPrimedTNT || this.entity.isFallingBlock)) { + final Entity entity = this.entity;
+ final me.samsuik.sakura.player.visibility.Visibility visibility = player.visibility;
+ if (visibility.isModified() || !(entity.isPrimedTNT || entity.isFallingBlock)) {
+ return true; + return true;
+ } + }
+ if (this.entity.isPrimedTNT && player.visibility.isToggled(me.samsuik.sakura.player.visibility.Visibility.Setting.TNT_VISIBILITY)) { + if (entity.isPrimedTNT && visibility.isToggled(me.samsuik.sakura.player.visibility.Visibility.Setting.TNT_VISIBILITY)) {
+ return false; + return false;
+ } + }
+ if (this.entity.isFallingBlock && player.visibility.isToggled(me.samsuik.sakura.player.visibility.Visibility.Setting.SAND_VISIBILITY)) { + if (entity.isFallingBlock && visibility.isToggled(me.samsuik.sakura.player.visibility.Visibility.Setting.SAND_VISIBILITY)) {
+ return false; + return false;
+ } + }
+ if (player.visibility.isToggled(me.samsuik.sakura.player.visibility.Visibility.Setting.MINIMAL)) { + if (visibility.isToggled(me.samsuik.sakura.player.visibility.Visibility.Setting.MINIMAL)) {
+ final long key = this.entity.blockPosition().asLong() ^ this.entity.getType().hashCode(); + final long key = entity.blockPosition().asLong() ^ entity.getType().hashCode();
+ final long visibleEntity = ChunkMap.this.minimalEntities.get(key); + final long visibleEntity = ChunkMap.this.minimalEntities.get(key);
+ if (visibleEntity != Integer.MIN_VALUE) { + if (visibleEntity != Integer.MIN_VALUE) {
+ return this.entity.getId() == visibleEntity; + return entity.getId() == visibleEntity;
+ } else { + } else {
+ ChunkMap.this.minimalEntities.put(key, this.entity.getId()); + ChunkMap.this.minimalEntities.put(key, entity.getId());
+ } + }
+ } + }
+ return true; + return true;
@@ -301,7 +303,7 @@ index af8cb316ac169aa8d98a88765b85bb013b9ba961..76d4b7e9dad6536c100e5940f9f528ba
public TrackedEntity(final Entity entity, final int i, final int j, final boolean flag) { public TrackedEntity(final Entity entity, final int i, final int j, final boolean flag) {
this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, j, flag, this::broadcast, this.seenBy); // CraftBukkit this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, j, flag, this::broadcast, this.seenBy); // CraftBukkit
@@ -1256,6 +1282,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1293,6 +1321,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
flag = flag && this.entity.broadcastToPlayer(player) && ChunkMap.this.isChunkTracked(player, this.entity.chunkPosition().x, this.entity.chunkPosition().z); flag = flag && this.entity.broadcastToPlayer(player) && ChunkMap.this.isChunkTracked(player, this.entity.chunkPosition().x, this.entity.chunkPosition().z);
// Paper end - Configurable entity tracking range by Y // Paper end - Configurable entity tracking range by Y
@@ -310,23 +312,23 @@ index af8cb316ac169aa8d98a88765b85bb013b9ba961..76d4b7e9dad6536c100e5940f9f528ba
// CraftBukkit start - respect vanish API // CraftBukkit start - respect vanish API
if (flag && !player.getBukkitEntity().canSee(this.entity.getBukkitEntity())) { // Paper - only consider hits if (flag && !player.getBukkitEntity().canSee(this.entity.getBukkitEntity())) { // Paper - only consider hits
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 1a0819301e0ce05c60b6cb961202a5c60697f6c1..94b130f9fd12ad077e66e5aa1c7b143ad97d96e5 100644 index 32742470eea2ec86c0fff02aa157bfcc89530ad3..de2f6a27ae4d76bf27f127f448e0692f93b2a971 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1793,7 +1793,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. @@ -1895,7 +1895,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
while (iterator.hasNext()) { while (iterator.hasNext()) {
ServerPlayer entityplayer = (ServerPlayer) iterator.next(); ServerPlayer entityplayer = (ServerPlayer) iterator.next();
- if (entityplayer.distanceToSqr(x, y, z) < 4096.0D) { - if (entityplayer.distanceToSqr(vec3d) < 4096.0D) {
+ if (entityplayer.distanceToSqr(x, y, z) < 4096.0D && !entityplayer.visibility.isToggled(me.samsuik.sakura.player.visibility.Visibility.Setting.EXPLOSIONS)) { // Sakura - visibility api + if (entityplayer.distanceToSqr(vec3d) < 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())); Optional<Vec3> optional = Optional.ofNullable((Vec3) serverexplosion.getHitPlayers().get(entityplayer));
}
} entityplayer.connection.send(new ClientboundExplodePacket(vec3d, optional, particleparam2, holder));
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index c396580a9cfd86ff261bed439bb4662ae88010b5..007bc568d3fb23f08790044aa3171727996927dc 100644 index cffbd3300967e5d80b5973b35a76235bb2aa1b73..ad85e5ebe00918a7fea4071351741566e4883dd0 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -282,6 +282,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple @@ -308,6 +308,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
public final int[] mobCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper public final int[] mobCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper
// Paper end - Optional per player mob spawns // Paper end - Optional per player mob spawns
public final int[] mobBackoffCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper - per player mob count backoff public final int[] mobBackoffCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper - per player mob count backoff
@@ -334,7 +336,7 @@ index c396580a9cfd86ff261bed439bb4662ae88010b5..007bc568d3fb23f08790044aa3171727
// CraftBukkit start // CraftBukkit start
public CraftPlayer.TransferCookieConnection transferCookieConnection; public CraftPlayer.TransferCookieConnection transferCookieConnection;
@@ -586,6 +587,15 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple @@ -678,6 +679,15 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
this.respawnDimension = (ResourceKey) dataresult1.resultOrPartial(logger1::error).orElse(Level.OVERWORLD); this.respawnDimension = (ResourceKey) dataresult1.resultOrPartial(logger1::error).orElse(Level.OVERWORLD);
} }
} }
@@ -350,7 +352,7 @@ index c396580a9cfd86ff261bed439bb4662ae88010b5..007bc568d3fb23f08790044aa3171727
this.spawnExtraParticlesOnFall = nbt.getBoolean("spawn_extra_particles_on_fall"); this.spawnExtraParticlesOnFall = nbt.getBoolean("spawn_extra_particles_on_fall");
Tag nbtbase = nbt.get("raid_omen_position"); Tag nbtbase = nbt.get("raid_omen_position");
@@ -664,6 +674,13 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple @@ -731,6 +741,13 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
}); });
} }
this.getBukkitEntity().setExtraData(nbt); // CraftBukkit this.getBukkitEntity().setExtraData(nbt); // CraftBukkit
@@ -365,10 +367,10 @@ index c396580a9cfd86ff261bed439bb4662ae88010b5..007bc568d3fb23f08790044aa3171727
nbt.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall); nbt.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall);
if (this.raidOmenPosition != null) { if (this.raidOmenPosition != null) {
diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
index 7174f8c89a7cdcf40ff28f6636ecfb23b13ccdaa..208a71435d9be5fa6f6612c0e6d5a843f6442685 100644 index b0bc66dc7248aae691dcab68b925b52a1695e63f..b1a04865b0efee94227f0868910fc00712bcd6fa 100644
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
@@ -43,6 +43,23 @@ import org.bukkit.craftbukkit.util.CraftLocation; @@ -44,6 +44,23 @@ import org.bukkit.craftbukkit.util.CraftLocation;
import org.bukkit.craftbukkit.util.Waitable; import org.bukkit.craftbukkit.util.Waitable;
import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerResourcePackStatusEvent; import org.bukkit.event.player.PlayerResourcePackStatusEvent;
@@ -392,7 +394,7 @@ index 7174f8c89a7cdcf40ff28f6636ecfb23b13ccdaa..208a71435d9be5fa6f6612c0e6d5a843
public abstract class ServerCommonPacketListenerImpl implements ServerCommonPacketListener, CraftPlayer.TransferCookieConnection { public abstract class ServerCommonPacketListenerImpl implements ServerCommonPacketListener, CraftPlayer.TransferCookieConnection {
@@ -100,6 +117,65 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack @@ -101,6 +118,65 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
protected final org.bukkit.craftbukkit.CraftServer cserver; protected final org.bukkit.craftbukkit.CraftServer cserver;
public boolean processedDisconnect; public boolean processedDisconnect;
@@ -458,7 +460,7 @@ index 7174f8c89a7cdcf40ff28f6636ecfb23b13ccdaa..208a71435d9be5fa6f6612c0e6d5a843
public CraftPlayer getCraftPlayer() { public CraftPlayer getCraftPlayer() {
return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity(); return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity();
// CraftBukkit end // CraftBukkit end
@@ -302,6 +378,12 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack @@ -309,6 +385,12 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
ClientboundSetDefaultSpawnPositionPacket packet6 = (ClientboundSetDefaultSpawnPositionPacket) packet; ClientboundSetDefaultSpawnPositionPacket packet6 = (ClientboundSetDefaultSpawnPositionPacket) packet;
this.player.compassTarget = CraftLocation.toBukkit(packet6.pos, this.getCraftPlayer().getWorld()); this.player.compassTarget = CraftLocation.toBukkit(packet6.pos, this.getCraftPlayer().getWorld());
} }
@@ -471,7 +473,7 @@ index 7174f8c89a7cdcf40ff28f6636ecfb23b13ccdaa..208a71435d9be5fa6f6612c0e6d5a843
// CraftBukkit end // CraftBukkit end
if (packet.isTerminal()) { if (packet.isTerminal()) {
this.close(); this.close();
@@ -315,8 +397,11 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack @@ -322,8 +404,11 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
CrashReport crashreport = CrashReport.forThrowable(throwable, "Sending packet"); CrashReport crashreport = CrashReport.forThrowable(throwable, "Sending packet");
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Packet being sent"); CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Packet being sent");
@@ -485,10 +487,10 @@ index 7174f8c89a7cdcf40ff28f6636ecfb23b13ccdaa..208a71435d9be5fa6f6612c0e6d5a843
throw new ReportedException(crashreport); 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 diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 064d52d4479727c6a32bf357be8da32d1760e7fc..b0b6bd0fe9c50a237d889e7bdcab290c8424af42 100644 index c4b016a2fb5c79fb3f191e243712bee7cbe5cd2c..d8767738733a4d936723c1dccd2c4d273407b649 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -3221,6 +3221,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @@ -3246,6 +3246,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
event.setCancelled(cancelled); event.setCancelled(cancelled);
AbstractContainerMenu oldContainer = this.player.containerMenu; // SPIGOT-1224 AbstractContainerMenu oldContainer = this.player.containerMenu; // SPIGOT-1224
@@ -497,10 +499,10 @@ index 064d52d4479727c6a32bf357be8da32d1760e7fc..b0b6bd0fe9c50a237d889e7bdcab290c
if (this.player.containerMenu != oldContainer) { if (this.player.containerMenu != oldContainer) {
return; return;
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 4b54d0ea31062972e68ee8fafe3cfaf68f65a5cd..d2e91843df93753a78bb9bd6839de287dc2ce4e5 100644 index 6574219da33a7b9a4906883e65b78d7806f6e67b..eec06c841ae4dc9b3bf9c59d47352b4bd859c9c8 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -549,6 +549,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -610,6 +610,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
} }
} }
// Paper end - optimise entity tracker // Paper end - optimise entity tracker
@@ -512,7 +514,7 @@ index 4b54d0ea31062972e68ee8fafe3cfaf68f65a5cd..d2e91843df93753a78bb9bd6839de287
public Entity(EntityType<?> type, Level world) { public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet(); 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 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 b83be9bbb9f348da83c0fd1ecc7f65c8a58b45b9..1bfdebe6c1057ee19fb96d8f0f571c9d20d14cc6 100644 index 06d9a519e64d4b8b8764b3ad7691ad93b5cee065..4a50ef9b25b9162815b879c60c294ed4be2edd5c 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -78,6 +78,7 @@ public class FallingBlockEntity extends Entity { @@ -78,6 +78,7 @@ public class FallingBlockEntity extends Entity {
@@ -524,22 +526,22 @@ index b83be9bbb9f348da83c0fd1ecc7f65c8a58b45b9..1bfdebe6c1057ee19fb96d8f0f571c9d
public FallingBlockEntity(Level world, double x, double y, double z, BlockState block) { 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 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 42bd2d9a1528b6210e4dfb56233062fd97c9743b..28a15f612239614c6c56974da5855ce3bfd7c89e 100644 index de87483600e55d88176fe25db621bbd3e464729f..5bd189fad703ac99d57258fa448dbcc103077297 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -57,6 +57,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { @@ -63,6 +63,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
public PrimedTnt(EntityType<? extends PrimedTnt> type, Level world) {
super(type, world); super(type, world);
this.explosionPower = 4.0F;
this.blocksBuilding = true; this.blocksBuilding = true;
+ this.isPrimedTNT = true; // Sakura + this.isPrimedTNT = true; // Sakura
} }
public PrimedTnt(Level world, double x, double y, double z, @Nullable LivingEntity igniter) { public PrimedTnt(Level world, double x, double y, double z, @Nullable LivingEntity igniter) {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 42d7660efe5baa6f796f2a7606686c765b6f2478..71f9c53cb3a3130adcbbf92a081fbe2b32efd626 100644 index 9e4c416ddeccff87ea9ed5b45a2ef04eae2280bf..20c271879a79cc23c57421782e1199e0d52dfc2f 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -547,6 +547,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -552,6 +552,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
this.getHandle().displayName = name == null ? this.getName() : name; this.getHandle().displayName = name == null ? this.getName() : name;
} }

View File

@@ -5,10 +5,10 @@ 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 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 28a15f612239614c6c56974da5855ce3bfd7c89e..ef245198ce6385c66f58e0dbcdebffbe6d2b625e 100644 index 5bd189fad703ac99d57258fa448dbcc103077297..eff8a8353b513da72e18f993fd41494291bdff3a 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -129,6 +129,14 @@ public class PrimedTnt extends Entity implements TraceableEntity { @@ -136,6 +136,14 @@ public class PrimedTnt extends Entity implements TraceableEntity {
} }
} }

View File

@@ -5,45 +5,44 @@ Subject: [PATCH] Load Chunks on Movement
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
index 748ab4d637ce463272bae4fdbab6842a27385126..ea6e252053b8910141aacd5bb82108d6abf3fb96 100644 index 3abd4ad6379c383c3a31931255292b42d9435694..149e461fcb23b2ed7ae8dcc09837de501ba9eafb 100644
--- a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java --- a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
@@ -1574,6 +1574,7 @@ public final class CollisionUtil { @@ -1910,6 +1910,7 @@ public final class CollisionUtil {
public static final int COLLISION_FLAG_COLLIDE_WITH_UNLOADED_CHUNKS = 1 << 1; 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_BORDER = 1 << 2;
public static final int COLLISION_FLAG_CHECK_ONLY = 1 << 3; public static final int COLLISION_FLAG_CHECK_ONLY = 1 << 3;
+ public static final int COLLISION_FLAG_ADD_TICKET = 1 << 4; // Sakura - load chunks on movement + public static final int COLLISION_FLAG_ADD_TICKET = 1 << 4; // Sakura - load chunks on movement
public static boolean getCollisionsForBlocksOrWorldBorder(final net.minecraft.world.level.Level world, final net.minecraft.world.entity.Entity entity, final net.minecraft.world.phys.AABB aabb, public static boolean getCollisionsForBlocksOrWorldBorder(final Level world, final Entity entity, final AABB aabb,
final java.util.List<net.minecraft.world.phys.shapes.VoxelShape> intoVoxel, final java.util.List<net.minecraft.world.phys.AABB> intoAABB, final List<VoxelShape> intoVoxel, final List<AABB> intoAABB,
@@ -1624,6 +1625,7 @@ public final class CollisionUtil { @@ -1960,6 +1961,7 @@ public final class CollisionUtil {
final int maxChunkZ = maxBlockZ >> 4; final int maxChunkZ = maxBlockZ >> 4;
final boolean loadChunks = (collisionFlags & COLLISION_FLAG_LOAD_CHUNKS) != 0; final boolean loadChunks = (collisionFlags & COLLISION_FLAG_LOAD_CHUNKS) != 0;
+ final boolean addTicket = (collisionFlags & COLLISION_FLAG_ADD_TICKET) != 0; // Sakura + final boolean addTicket = (collisionFlags & COLLISION_FLAG_ADD_TICKET) != 0; // Sakura - load chunks on movement
final net.minecraft.world.level.chunk.ChunkSource chunkSource = world.getChunkSource(); final ChunkSource chunkSource = world.getChunkSource();
for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) { for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) {
@@ -1642,6 +1644,14 @@ public final class CollisionUtil { @@ -1978,6 +1980,13 @@ public final class CollisionUtil {
continue; continue;
} }
+ // Sakura start - load chunks on movement + // Sakura start - load chunks on movement
+ if (addTicket && chunk.movementTicketNeedsUpdate() && chunkSource instanceof net.minecraft.server.level.ServerChunkCache chunkCache) { + if (addTicket && chunk.movementTicketNeedsUpdate() && chunkSource instanceof net.minecraft.server.level.ServerChunkCache chunkCache) {
+ final long chunkKey = ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(currChunkX, currChunkZ); + final long chunkKey = ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(currChunkX, currChunkZ);
+ chunkCache.chunkMap.getDistanceManager().getChunkHolderManager().addTicketAtLevel(net.minecraft.server.level.TicketType.ENTITY_MOVEMENT, currChunkX, currChunkZ, 31, chunkKey); + chunkCache.chunkMap.getDistanceManager().moonrise$getChunkHolderManager().addTicketAtLevel(net.minecraft.server.level.TicketType.ENTITY_MOVEMENT, currChunkX, currChunkZ, 31, chunkKey);
+ chunk.updatedMovementTicket(); + chunk.updatedMovementTicket();
+ } + }
+ // Sakura end - load chunks on movement + // Sakura end - load chunks on movement
+ final LevelChunkSection[] sections = chunk.getSections();
final net.minecraft.world.level.chunk.LevelChunkSection[] sections = chunk.getSections();
// bound y // bound y
diff --git a/src/main/java/net/minecraft/server/level/TicketType.java b/src/main/java/net/minecraft/server/level/TicketType.java diff --git a/src/main/java/net/minecraft/server/level/TicketType.java b/src/main/java/net/minecraft/server/level/TicketType.java
index f56e5c0f53f9b52a9247b9be9265b949494fc924..f8e0746433057297c88f0237502da85622297cef 100644 index e701f57ac8b0efdf739389f9be7a255220bb3e21..35a437f3acfd2659341abd8ab6a3b21c00594ba9 100644
--- a/src/main/java/net/minecraft/server/level/TicketType.java --- a/src/main/java/net/minecraft/server/level/TicketType.java
+++ b/src/main/java/net/minecraft/server/level/TicketType.java +++ b/src/main/java/net/minecraft/server/level/TicketType.java
@@ -25,6 +25,7 @@ public class TicketType<T> { @@ -26,6 +26,7 @@ public class TicketType<T> {
public static final TicketType<ChunkPos> UNKNOWN = TicketType.create("unknown", Comparator.comparingLong(ChunkPos::toLong), 1); public static final TicketType<ChunkPos> UNKNOWN = TicketType.create("unknown", Comparator.comparingLong(ChunkPos::toLong), 1);
public static final TicketType<Unit> PLUGIN = TicketType.create("plugin", (a, b) -> 0); // CraftBukkit public static final TicketType<Unit> PLUGIN = TicketType.create("plugin", (a, b) -> 0); // CraftBukkit
public static final TicketType<org.bukkit.plugin.Plugin> PLUGIN_TICKET = TicketType.create("plugin_ticket", (plugin1, plugin2) -> plugin1.getClass().getName().compareTo(plugin2.getClass().getName())); // CraftBukkit public static final TicketType<org.bukkit.plugin.Plugin> PLUGIN_TICKET = TicketType.create("plugin_ticket", (plugin1, plugin2) -> plugin1.getClass().getName().compareTo(plugin2.getClass().getName())); // CraftBukkit
@@ -52,10 +51,10 @@ index f56e5c0f53f9b52a9247b9be9265b949494fc924..f8e0746433057297c88f0237502da856
public static <T> TicketType<T> create(String name, Comparator<T> argumentComparator) { public static <T> TicketType<T> create(String name, Comparator<T> argumentComparator) {
return new TicketType<>(name, argumentComparator, 0L); 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 diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index d2e91843df93753a78bb9bd6839de287dc2ce4e5..87a117c74dcee2e58126e133b853a56a7965e55f 100644 index eec06c841ae4dc9b3bf9c59d47352b4bd859c9c8..4be6b57d11c48da84a58b025fddb2b6aafaec55a 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -553,6 +553,20 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -614,6 +614,20 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
public boolean isPrimedTNT; public boolean isPrimedTNT;
public boolean isFallingBlock; public boolean isFallingBlock;
// Sakura end - visibility api and command // Sakura end - visibility api and command
@@ -76,16 +75,16 @@ index d2e91843df93753a78bb9bd6839de287dc2ce4e5..87a117c74dcee2e58126e133b853a56a
public Entity(EntityType<?> type, Level world) { public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet(); this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -1504,7 +1518,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1591,7 +1605,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getCollisions( ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getCollisionsForBlocksOrWorldBorder(
world, (Entity)(Object)this, collisionBox, potentialCollisionsVoxel, potentialCollisionsBB, this.level, (Entity)(Object)this, initialCollisionBox, potentialCollisionsVoxel, potentialCollisionsBB,
- ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER, - ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER, null
+ ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER | this.getExtraCollisionFlags(), // Sakura - load chunks on movement + ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER | this.getExtraCollisionFlags(), null // Sakura - load chunks on movement
null, null
); );
potentialCollisionsBB.addAll(entityAABBs);
@@ -4874,12 +4888,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess final Vec3 collided = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.performCollisions(movement, currentBox, potentialCollisionsVoxel, potentialCollisionsBB);
@@ -5205,12 +5219,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@Override @Override
public boolean shouldBeSaved() { public boolean shouldBeSaved() {
@@ -99,9 +98,9 @@ index d2e91843df93753a78bb9bd6839de287dc2ce4e5..87a117c74dcee2e58126e133b853a56a
+ return this.loadChunks; // Sakura - load chunks on movement; always tick in unloaded & lazy chunks + return this.loadChunks; // Sakura - load chunks on movement; always tick in unloaded & lazy chunks
} }
public boolean mayInteract(Level world, BlockPos pos) { public boolean mayInteract(ServerLevel 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 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 1bfdebe6c1057ee19fb96d8f0f571c9d20d14cc6..eaafd4905229d111381c188d5373196a9f9288ab 100644 index 4a50ef9b25b9162815b879c60c294ed4be2edd5c..6127993804a8c0b342d74c62f163b8371f7c049b 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -79,6 +79,7 @@ public class FallingBlockEntity extends Entity { @@ -79,6 +79,7 @@ public class FallingBlockEntity extends Entity {
@@ -113,11 +112,11 @@ index 1bfdebe6c1057ee19fb96d8f0f571c9d20d14cc6..eaafd4905229d111381c188d5373196a
public FallingBlockEntity(Level world, double x, double y, double z, BlockState block) { 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 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 ef245198ce6385c66f58e0dbcdebffbe6d2b625e..b7c8c2335d59853dbc97d3b9496b5e3a63f0d9ab 100644 index eff8a8353b513da72e18f993fd41494291bdff3a..2ddfea0dd64cf6a2295583b747ab195346c24530 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -58,6 +58,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { @@ -64,6 +64,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
super(type, world); this.explosionPower = 4.0F;
this.blocksBuilding = true; this.blocksBuilding = true;
this.isPrimedTNT = true; // Sakura this.isPrimedTNT = true; // Sakura
+ this.loadChunks = world.sakuraConfig().cannons.loadChunks; // Sakura - load chunks on movement + this.loadChunks = world.sakuraConfig().cannons.loadChunks; // Sakura - load chunks on movement
@@ -125,10 +124,10 @@ index ef245198ce6385c66f58e0dbcdebffbe6d2b625e..b7c8c2335d59853dbc97d3b9496b5e3a
public PrimedTnt(Level world, double x, double y, double z, @Nullable LivingEntity igniter) { public PrimedTnt(Level world, double x, double y, double z, @Nullable LivingEntity igniter) {
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
index 75c8125e20b70433fe9d143a3193d821043327c3..20764fba3c7cfe26cf622c3ee4848839408fa6af 100644 index a402e2f774cfc062afab8d86969f3e6f38874063..d95c15bff4e7ab241c63b0abeaaaca0d07fd77ae 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java --- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
@@ -140,6 +140,17 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom @@ -140,6 +140,17 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh
private final int minSection; private final int minSection;
private final int maxSection; private final int maxSection;
// Paper end - get block chunk optimisation // Paper end - get block chunk optimisation

View File

@@ -414,10 +414,10 @@ index 0000000000000000000000000000000000000000..6903863ad293a335a8ed1aeaa06fccb4
+ +
+} +}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 7499ee50e3c62c3107979ea8a100f1da96f2c980..4c53e39aa153f490a473175df00679d0d01d2bd0 100644 index 3ef2f8b523b940db18a5d512f21f037fc799f487..873f37587a850fab964c11e96411252fd01e29f9 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1210,6 +1210,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1230,6 +1230,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)); private static final java.math.BigDecimal TPS_BASE = new java.math.BigDecimal(1E9).multiply(new java.math.BigDecimal(SAMPLE_INTERVAL));
@@ -425,7 +425,7 @@ index 7499ee50e3c62c3107979ea8a100f1da96f2c980..4c53e39aa153f490a473175df00679d0
// Paper end // Paper end
// Spigot End // Spigot End
@@ -1279,6 +1280,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1299,6 +1300,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
if (++MinecraftServer.currentTick % MinecraftServer.SAMPLE_INTERVAL == 0) { if (++MinecraftServer.currentTick % MinecraftServer.SAMPLE_INTERVAL == 0) {
final long diff = currentTime - tickSection; final long diff = currentTime - tickSection;
final java.math.BigDecimal currentTps = TPS_BASE.divide(new java.math.BigDecimal(diff), 30, java.math.RoundingMode.HALF_UP); final java.math.BigDecimal currentTps = TPS_BASE.divide(new java.math.BigDecimal(diff), 30, java.math.RoundingMode.HALF_UP);
@@ -433,19 +433,19 @@ index 7499ee50e3c62c3107979ea8a100f1da96f2c980..4c53e39aa153f490a473175df00679d0
tps1.add(currentTps, diff); tps1.add(currentTps, diff);
tps5.add(currentTps, diff); tps5.add(currentTps, diff);
tps15.add(currentTps, diff); tps15.add(currentTps, diff);
@@ -1314,6 +1316,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1341,6 +1343,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
throw new RuntimeException("Chunk system crash propagated to tick()", crash); throw new RuntimeException("Chunk system crash propagated to tick()", crash);
} }
// Paper end - rewrite chunk system // Paper end - rewrite chunk system
+ tickTracking.tickSample((System.nanoTime() - currentTime) / 1_000_000L); // Sakura - add tps graph command + tickTracking.tickSample((System.nanoTime() - currentTime) / 1_000_000L); // Sakura - add tps graph command
this.profiler.popPush("nextTickWait"); this.tickFrame.end();
this.mayHaveDelayedTasks = true; gameprofilerfiller.popPush("nextTickWait");
this.delayedTasksMaxNextTickTimeNanos = Math.max(Util.getNanos() + i, this.nextTickTimeNanos); this.mayHaveDelayedTasks = true;
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index dcb5651d1d9b10b40430fb2f713beedf68336704..601dbdec2476757cdaf8b6a9cc7e8cae3a3fba2e 100644 index 3c711e1df57ac5b0f8795ebb12299d275792b1d4..837cbd35b52c861956eef1eea0ae782a311273ba 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -143,6 +143,11 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon @@ -193,6 +193,11 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
this.clearCache(); this.clearCache();
} }
@@ -458,15 +458,15 @@ index dcb5651d1d9b10b40430fb2f713beedf68336704..601dbdec2476757cdaf8b6a9cc7e8cae
public boolean isChunkLoaded(int chunkX, int chunkZ) { public boolean isChunkLoaded(int chunkX, int chunkZ) {
ChunkHolder chunk = this.chunkMap.getUpdatingChunkIfPresent(ChunkPos.asLong(chunkX, chunkZ)); ChunkHolder chunk = this.chunkMap.getUpdatingChunkIfPresent(ChunkPos.asLong(chunkX, chunkZ));
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 07f36cd0dea417459e7022fe7e73a5177fc7c67a..61ebb6db40626442b75cf768e1bacce3c5c09ec0 100644 index de2f6a27ae4d76bf27f127f448e0692f93b2a971..ac43d1d91f7ac554f1267b3d76e22bd8f06d8f08 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -198,7 +198,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. @@ -200,7 +200,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
private final MinecraftServer server; private final MinecraftServer server;
public final PrimaryLevelData serverLevelData; // CraftBukkit - type public final PrimaryLevelData serverLevelData; // CraftBukkit - type
private int lastSpawnChunkRadius; private int lastSpawnChunkRadius;
- final EntityTickList entityTickList; - final EntityTickList entityTickList = new EntityTickList();
+ public final EntityTickList entityTickList; // Sakura - package-private -> public + public final EntityTickList entityTickList = new EntityTickList(); // Sakura - package-private -> public
// Paper - rewrite chunk system // Paper - rewrite chunk system
private final GameEventDispatcher gameEventDispatcher; private final GameEventDispatcher gameEventDispatcher;
public boolean noSave; public boolean noSave;

View File

@@ -5,62 +5,54 @@ 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 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 1c0712295695727ee9c4d430d4157b8e17cbd71f..1c82ff348769655f20ba4fde7914a326e072afce 100644 index f4fbcbb8ff6d2677af1a02a0801a323c06dce9b1..4613162b6e716e33a838c59171c486b9c4d4b097 100644
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java --- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
+++ b/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 { @@ -181,7 +181,7 @@ public abstract class FlowingFluid extends Fluid {
BlockState iblockdata = world.getBlockState(fluidPos); FluidState fluid1 = iblockdata1.getFluidState();
BlockPos blockposition1 = fluidPos.below();
BlockState iblockdata1 = world.getBlockState(blockposition1);
- FluidState fluid1 = this.getNewLiquid(world, blockposition1, iblockdata1);
+ FluidState fluid1 = this.getLiquid(world, blockposition1, iblockdata1, fluidPos, iblockdata); // Sakura - optimise new liquid level
if (this.canSpreadTo(world, fluidPos, iblockdata, Direction.DOWN, blockposition1, iblockdata1, world.getFluidState(blockposition1), fluid1.getType())) { if (this.canMaybePassThrough(world, fluidPos, blockState, Direction.DOWN, blockposition1, iblockdata1, fluid1)) {
// CraftBukkit start - FluidState fluid2 = this.getNewLiquid(world, blockposition1, iblockdata1);
@@ -197,6 +197,25 @@ public abstract class FlowingFluid extends Fluid { + FluidState fluid2 = this.getLiquid(world, blockposition1, iblockdata1, fluidPos, blockState); // Sakura - optimise new liquid level
Fluid fluidtype = fluid2.getType();
if (fluid1.canBeReplacedWith(world, blockposition1, fluidtype, Direction.DOWN) && FlowingFluid.canHoldSpecificFluid(world, blockposition1, iblockdata1, fluidtype)) {
@@ -245,6 +245,23 @@ public abstract class FlowingFluid extends Fluid {
} }
protected FluidState getNewLiquid(Level world, BlockPos pos, BlockState state) { protected FluidState getNewLiquid(ServerLevel world, BlockPos pos, BlockState state) {
+ // Sakura start - optimise new liquid level + // Sakura start - optimise new liquid level
+ BlockPos blockposition2 = pos.above(); + final BlockPos abovePos = pos.above();
+ BlockState iblockdata3 = world.getBlockState(blockposition2); + final BlockState aboveState = world.getBlockState(abovePos);
+ + return this.getLiquid(world, pos, state, abovePos, aboveState);
+ return getLiquid(world, pos, state, blockposition2, iblockdata3);
+ } + }
+ +
+ // SANITY: world, pos, state, above pos, above state + private FluidState getLiquid(final ServerLevel world, final BlockPos flowToPos, final BlockState flowToState, final BlockPos abovePos, final BlockState aboveState) {
+ protected FluidState getLiquid(Level world, BlockPos pos, BlockState state, BlockPos blockposition2, BlockState iblockdata3) { + final FluidState aboveFluid = aboveState.getFluidState();
+ FluidState fluid2 = iblockdata3.getFluidState(); + if (!aboveFluid.isEmpty() && aboveFluid.getType().isSame(this) && FlowingFluid.canPassThroughWall(Direction.UP, world, flowToPos, flowToState, abovePos, aboveState)) {
+
+ if (!fluid2.isEmpty() && fluid2.getType().isSame(this) && this.canPassThroughWall(Direction.UP, world, pos, state, blockposition2, iblockdata3)) {
+ return this.getFlowing(8, true); + return this.getFlowing(8, true);
+ } else { + } else {
+ return this.getLiquidFromSurroundings(world, pos, state); + return this.getLiquidFromSurroundings(world, flowToPos, flowToState);
+ } + }
+ } + }
+ +
+ protected FluidState getLiquidFromSurroundings(Level world, BlockPos pos, BlockState state) { + private FluidState getLiquidFromSurroundings(final ServerLevel world, final BlockPos pos, final BlockState state) {
+ // Sakura start - optimise new liquid level
int i = 0; int i = 0;
int j = 0; int j = 0;
Iterator iterator = Direction.Plane.HORIZONTAL.iterator(); BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
@@ -226,17 +245,10 @@ public abstract class FlowingFluid extends Fluid { @@ -275,13 +292,7 @@ public abstract class FlowingFluid extends Fluid {
} }
} }
- BlockPos blockposition2 = pos.above(); - BlockPos.MutableBlockPos blockposition_mutableblockposition2 = blockposition_mutableblockposition.setWithOffset(pos, Direction.UP);
- BlockState iblockdata3 = world.getBlockState(blockposition2); - BlockState iblockdata3 = world.getBlockState(blockposition_mutableblockposition2);
- FluidState fluid2 = iblockdata3.getFluidState(); - FluidState fluid2 = iblockdata3.getFluidState();
+ int k = i - this.getDropOff(world); -
- if (!fluid2.isEmpty() && fluid2.getType().isSame(this) && FlowingFluid.canPassThroughWall(Direction.UP, world, pos, state, blockposition_mutableblockposition2, iblockdata3)) {
- if (!fluid2.isEmpty() && fluid2.getType().isSame(this) && this.canPassThroughWall(Direction.UP, world, pos, state, blockposition2, iblockdata3)) {
- return this.getFlowing(8, true); - return this.getFlowing(8, true);
- } else { - } else {
- int k = i - this.getDropOff(world); + { // Sakura - optimise new liquid level
- int k = i - this.getDropOff(world);
- return k <= 0 ? Fluids.EMPTY.defaultFluidState() : this.getFlowing(k, false);
- }
+ return k <= 0 ? Fluids.EMPTY.defaultFluidState() : this.getFlowing(k, false);
+ // Sakura end - optimise new liquid level
}
private boolean canPassThroughWall(Direction face, BlockGetter world, BlockPos pos, BlockState state, BlockPos fromPos, BlockState fromState) { return k <= 0 ? Fluids.EMPTY.defaultFluidState() : this.getFlowing(k, false);

View File

@@ -155,19 +155,19 @@ index 0f99733660f91280e4c6262cf75b3c9cae86f65a..ba9f8fe6fafc54bbdfb104de28af4b39
return SynchedEntityData.DataValue.create(this.accessor, this.value); 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 diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index 8ea2f24695f5dad55e21f238b69442513e7a90c6..66ce58684d7a571ebcb33e62ef1d67fe3f1250e3 100644 index 90eb4927fa51ce3df86aa7b6c71f49150a03e337..a960c7ac83cb32b2eb1f292fd9a561bae5677324 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java --- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -152,7 +152,7 @@ public class ServerEntity { @@ -156,7 +156,7 @@ public class ServerEntity {
} }
} }
- if (this.forceStateResync || this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) { // Paper - fix desync when a player is added to the tracker - if (this.forceStateResync || this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) { // Paper - fix desync when a player is added to the tracker
+ if (this.forceStateResync || this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isForeignDirty()) { // Slice // Paper - fix desync when a player is added to the tracker + if (this.forceStateResync || this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isForeignDirty()) { // Slice // Paper - fix desync when a player is added to the tracker
int i; byte b0 = Mth.packDegrees(this.entity.getYRot());
int j; byte b1 = Mth.packDegrees(this.entity.getXRot());
boolean flag = Math.abs(b0 - this.lastSentYRot) >= 1 || Math.abs(b1 - this.lastSentXRot) >= 1;
@@ -411,7 +411,15 @@ public class ServerEntity { @@ -449,7 +449,15 @@ public class ServerEntity {
if (list != null) { if (list != null) {
this.trackedDataValues = datawatcher.getNonDefaultValues(); this.trackedDataValues = datawatcher.getNonDefaultValues();
@@ -185,10 +185,10 @@ index 8ea2f24695f5dad55e21f238b69442513e7a90c6..66ce58684d7a571ebcb33e62ef1d67fe
if (this.entity instanceof LivingEntity) { 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 diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 87a117c74dcee2e58126e133b853a56a7965e55f..9c890b1bc77834799abdbb403aeeb928ed0125ec 100644 index 4be6b57d11c48da84a58b025fddb2b6aafaec55a..2d8618541d2e673686485901ffc8e693545354a3 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -3495,7 +3495,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -3708,7 +3708,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
this.entityData.markDirty(Entity.DATA_AIR_SUPPLY_ID); this.entityData.markDirty(Entity.DATA_AIR_SUPPLY_ID);
return; return;
} }
@@ -198,10 +198,10 @@ index 87a117c74dcee2e58126e133b853a56a7965e55f..9c890b1bc77834799abdbb403aeeb928
} }
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java 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 eaafd4905229d111381c188d5373196a9f9288ab..0891d4107c9a724522a7abbb6cf61298b18e42a6 100644 index 6127993804a8c0b342d74c62f163b8371f7c049b..35d8422ea3bcdc52db6a7f6702fd593346b30c2c 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -115,7 +115,7 @@ public class FallingBlockEntity extends Entity { @@ -124,7 +124,7 @@ public class FallingBlockEntity extends Entity {
} }
public void setStartPos(BlockPos pos) { public void setStartPos(BlockPos pos) {
@@ -211,10 +211,10 @@ index eaafd4905229d111381c188d5373196a9f9288ab..0891d4107c9a724522a7abbb6cf61298
public BlockPos getStartPos() { 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 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 b7c8c2335d59853dbc97d3b9496b5e3a63f0d9ab..888d018a8e73234332455b7d3700e70e1a50c5db 100644 index 2ddfea0dd64cf6a2295583b747ab195346c24530..25a25b5c6497c9823a41e6bd8fd22f0841377c62 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -203,7 +203,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { @@ -217,7 +217,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
} }
public void setFuse(int fuse) { public void setFuse(int fuse) {
@@ -224,10 +224,10 @@ index b7c8c2335d59853dbc97d3b9496b5e3a63f0d9ab..888d018a8e73234332455b7d3700e70e
public int getFuse() { 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 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 09bcbc0ae36e4e69fee87a7e0c49acf496117a39..8b2b495f34b1ae96901ed8f2ca2d8d753b4eb2c8 100644 index 61d412c4f1ebd55661cc3f0260468e3ac0efe0bb..c3e90356ab409f408b767618db718e3926edf8d1 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java --- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -650,7 +650,7 @@ public abstract class Player extends LivingEntity { @@ -676,7 +676,7 @@ public abstract class Player extends LivingEntity {
public void increaseScore(int score) { public void increaseScore(int score) {
int j = this.getScore(); int j = this.getScore();

View File

@@ -5,15 +5,15 @@ 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 diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 76d4b7e9dad6536c100e5940f9f528ba2561e3b8..e80e1d7ac52ef6f81dab85916f8107bc3e9339c6 100644 index 464fc90376075ecc46f7b7731ba5e2c705324e7d..dff0b8a1f2afcef21ca7e7aea3ee635826a2e9ef 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -180,7 +180,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -187,7 +187,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.toDrop = new LongOpenHashSet(); this.toDrop = new LongOpenHashSet();
this.tickingGenerated = new AtomicInteger(); this.tickingGenerated = new AtomicInteger();
this.playerMap = new PlayerMap(); this.playerMap = new PlayerMap();
- this.entityMap = new Int2ObjectOpenHashMap(); - this.entityMap = new Int2ObjectOpenHashMap();
+ this.entityMap = new me.samsuik.sakura.utils.collections.TrackedEntityChunkMap(); // Sakura - optimised tracked entity map + this.entityMap = new me.samsuik.sakura.utils.collections.TrackedEntityChunkMap(); // Sakura - optimised tracked entity map
this.chunkTypeCache = new Long2ByteOpenHashMap(); this.chunkTypeCache = new Long2ByteOpenHashMap();
this.chunkSaveCooldowns = new Long2LongOpenHashMap();
// Paper - rewrite chunk system // Paper - rewrite chunk system
Path path = session.getDimensionPath(world.dimension());

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Copy EntityList methods to BasicEntityList
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
index 87d2b3ec165e2e9e4bdbedd7adddaa2130ed507b..01e29fc7c91aa7ffeb54584c8ca0989900235251 100644 index b3c993a790fc3fab6a408c731deb297f74c959ce..a24c509fc1f1052047d73847aacdd863fe8ea6e1 100644
--- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java --- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
@@ -413,6 +413,13 @@ public final class ChunkEntitySlices { @@ -392,6 +392,13 @@ public final class ChunkEntitySlices {
private E[] storage; private E[] storage;
private int size; private int size;
@@ -22,7 +22,7 @@ index 87d2b3ec165e2e9e4bdbedd7adddaa2130ed507b..01e29fc7c91aa7ffeb54584c8ca09899
public BasicEntityList() { public BasicEntityList() {
this(0); this(0);
@@ -433,6 +440,7 @@ public final class ChunkEntitySlices { @@ -412,6 +419,7 @@ public final class ChunkEntitySlices {
private void resize() { private void resize() {
if (this.storage == EMPTY) { if (this.storage == EMPTY) {
this.storage = (E[])new Entity[DEFAULT_CAPACITY]; this.storage = (E[])new Entity[DEFAULT_CAPACITY];
@@ -30,7 +30,7 @@ index 87d2b3ec165e2e9e4bdbedd7adddaa2130ed507b..01e29fc7c91aa7ffeb54584c8ca09899
} else { } else {
this.storage = Arrays.copyOf(this.storage, this.storage.length * 2); this.storage = Arrays.copyOf(this.storage, this.storage.length * 2);
} }
@@ -446,6 +454,7 @@ public final class ChunkEntitySlices { @@ -425,6 +433,7 @@ public final class ChunkEntitySlices {
} else { } else {
this.storage[idx] = entity; this.storage[idx] = entity;
} }
@@ -38,7 +38,7 @@ index 87d2b3ec165e2e9e4bdbedd7adddaa2130ed507b..01e29fc7c91aa7ffeb54584c8ca09899
} }
public int indexOf(final E entity) { public int indexOf(final E entity) {
@@ -461,24 +470,32 @@ public final class ChunkEntitySlices { @@ -440,24 +449,32 @@ public final class ChunkEntitySlices {
} }
public boolean remove(final E entity) { public boolean remove(final E entity) {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Add utility methods to EntitySlices
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
index 01e29fc7c91aa7ffeb54584c8ca0989900235251..8126c4fdbbc586cf3722c6ee2986338de044602e 100644 index a24c509fc1f1052047d73847aacdd863fe8ea6e1..88b1a9b4b3da23b8e500ec343915e66e9b4f19b6 100644
--- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java --- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
@@ -318,6 +318,12 @@ public final class ChunkEntitySlices { @@ -297,6 +297,12 @@ public final class ChunkEntitySlices {
return true; return true;
} }
@@ -21,7 +21,7 @@ index 01e29fc7c91aa7ffeb54584c8ca0989900235251..8126c4fdbbc586cf3722c6ee2986338d
public void getHardCollidingEntities(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate) { 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); this.hardCollidingEntities.getEntities(except, box, into, predicate);
} }
@@ -542,6 +548,18 @@ public final class ChunkEntitySlices { @@ -521,6 +527,18 @@ public final class ChunkEntitySlices {
} }
} }

View File

@@ -4,11 +4,11 @@ Date: Fri, 19 Apr 2024 22:20:03 +0100
Subject: [PATCH] Optimise paper explosions Subject: [PATCH] Optimise paper explosions
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java
index f696afd7e241bf1966a2d505b5d59bff824b43e4..611fc40fd7461f6d9cd9e737de71e702bf1f36c5 100644 index bbbd451ff184be8fa13bd93d53c89a9502f9951a..a92be80081178cc302a7f0b646bad7daa28f7c66 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java --- a/src/main/java/net/minecraft/world/level/ServerExplosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java
@@ -101,7 +101,7 @@ public class Explosion { @@ -89,7 +89,7 @@ public class ServerExplosion implements Explosion {
} }
} }
@@ -17,10 +17,10 @@ index f696afd7e241bf1966a2d505b5d59bff824b43e4..611fc40fd7461f6d9cd9e737de71e702
} }
private static final int CHUNK_CACHE_SHIFT = 2; private static final int CHUNK_CACHE_SHIFT = 2;
@@ -316,6 +316,39 @@ public class Explosion { @@ -307,6 +307,39 @@ public class ServerExplosion implements Explosion {
return (float)missedRays / (float)totalRays; return (float)missedRays / (float)totalRays;
} }
// Paper end - optimise collisions // Paper end - collisions optimisations
+ // Sakura start - optimise paper explosions + // Sakura start - optimise paper explosions
+ /* + /*
+ * Sort the explosion rays to better utilise the chunk and block cache. + * Sort the explosion rays to better utilise the chunk and block cache.
@@ -31,7 +31,7 @@ index f696afd7e241bf1966a2d505b5d59bff824b43e4..611fc40fd7461f6d9cd9e737de71e702
+ * 2 3 8 2 + * 2 3 8 2
+ * 1 1 + * 1 1
+ */ + */
+ private static double[] sortExplosionRays(final it.unimi.dsi.fastutil.doubles.DoubleArrayList rayCoords) { + private static double[] sortExplosionRays(it.unimi.dsi.fastutil.doubles.DoubleArrayList rayCoords) {
+ List<double[]> explosionRays = new ArrayList<>(); + List<double[]> explosionRays = new ArrayList<>();
+ +
+ for (int i = 0; i < rayCoords.size(); i += 3) { + for (int i = 0; i < rayCoords.size(); i += 3) {
@@ -55,69 +55,55 @@ index f696afd7e241bf1966a2d505b5d59bff824b43e4..611fc40fd7461f6d9cd9e737de71e702
+ } + }
+ // Sakura end - optimise paper explosions + // Sakura end - optimise paper explosions
public static DamageSource getDefaultDamageSource(Level world, @Nullable Entity source) { public ServerExplosion(ServerLevel world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, Vec3 pos, float power, boolean createFire, Explosion.BlockInteraction destructionType) {
return world.damageSources().explosion(source, Explosion.getIndirectSourceEntityInternal(source)); this.level = world;
@@ -439,6 +472,16 @@ public class Explosion { @@ -389,6 +422,12 @@ public class ServerExplosion implements Explosion {
int j; initialCache = this.getOrCacheExplosionBlock(blockX, blockY, blockZ, key, true);
}
// Paper start - collision optimisations
+ // Sakura start - optimise paper explosions + // Sakura start - optimise paper explosions
+ if (initialCache.resistance <= (this.radius * 1.3f) && this.interactsWithBlocks()) { + if (!this.interactsWithBlocks() || initialCache.resistance > (this.radius * 1.3f)) {
+ this.searchForBlocks(blockCache, initialCache); + return ret;
+ } + }
+ this.locateAndImpactEntities(blockCache);
+ this.clearBlockCache();
+ }
+
+ protected final void searchForBlocks(ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[] blockCache, final ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache initialCache) {
+ // Sakura end - optimise paper explosions + // Sakura end - optimise paper explosions
for (int ray = 0, len = CACHED_RAYS.length; ray < len;) {
ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache cachedBlock = initialCache;
@@ -510,25 +553,64 @@ public class Explosion {
}
// Paper - optimise collisions
- float f2 = this.radius * 2.0F;
+ // Sakura start - optimise paper explosions
+ }
- i = Mth.floor(this.x - (double) f2 - 1.0D);
- j = Mth.floor(this.x + (double) f2 + 1.0D);
+ protected final AABB getExplosionBounds(float f2) {
+ // Sakura - moved into locateAndImpactEntities
+ +
+ int i = Mth.floor(this.x - (double) f2 - 1.0D); // only ~1/3rd of the loop iterations in vanilla will result in a ray, as it is iterating the perimeter of
+ int j = Mth.floor(this.x + (double) f2 + 1.0D); // a 16x16x16 cube
int l = Mth.floor(this.y - (double) f2 - 1.0D); // we can cache the rays and their normals as well, so that we eliminate the excess iterations / checks and
int i1 = Mth.floor(this.y + (double) f2 + 1.0D); @@ -467,19 +506,55 @@ public class ServerExplosion implements Explosion {
int j1 = Mth.floor(this.z - (double) f2 - 1.0D); // Paper end - collision optimisations
int k1 = Mth.floor(this.z + (double) f2 + 1.0D); }
- List<Entity> list = this.level.getEntities(excludeSourceFromDamage ? this.source : null, new AABB((double) i, (double) l, (double) j1, (double) j, (double) i1, (double) k1), (com.google.common.base.Predicate<Entity>) entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source
+ return new AABB((double) i, (double) l, (double) j1, (double) j, (double) i1, (double) k1); - private void hurtEntities() {
+ } - float f = this.radius * 2.0F;
+ + // Sakura start - optimise paper explosions
+ protected final void locateAndImpactEntities(ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[] blockCache) { + protected final AABB getExplosionBounds(float f) {
+ float f2 = this.radius * 2.0F; int i = Mth.floor(this.center.x - (double) f - 1.0D);
Vec3 vec3d = new Vec3(this.x, this.y, this.z); int j = Mth.floor(this.center.x + (double) f + 1.0D);
int k = Mth.floor(this.center.y - (double) f - 1.0D);
int l = Mth.floor(this.center.y + (double) f + 1.0D);
int i1 = Mth.floor(this.center.z - (double) f - 1.0D);
int j1 = Mth.floor(this.center.z + (double) f + 1.0D);
- List<Entity> list = this.level.getEntities(excludeSourceFromDamage ? this.source : null, new AABB((double) i, (double) k, (double) i1, (double) j, (double) l, (double) j1), (com.google.common.base.Predicate<Entity>) entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source
- Iterator iterator = list.iterator(); - Iterator iterator = list.iterator();
+ return new AABB((double) i, (double) k, (double) i1, (double) j, (double) l, (double) j1);
// Paper start - optimise collisions + }
final BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos();
// Paper end - optimise collisions
- while (iterator.hasNext()) { - while (iterator.hasNext()) {
- Entity entity = (Entity) iterator.next(); - Entity entity = (Entity) iterator.next();
+ private void hurtEntities() {
+ float f = this.radius * 2.0F;
+
+ int minSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMinSection(this.level); + int minSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMinSection(this.level);
+ int maxSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMaxSection(this.level); + int maxSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMaxSection(this.level);
+ +
+ int minChunkX = Mth.floor(this.x - f2) >> 4; + int minChunkX = Mth.floor(this.center.x - f) >> 4;
+ int maxChunkX = Mth.floor(this.x + f2) >> 4; + int maxChunkX = Mth.floor(this.center.x + f) >> 4;
+ int minChunkY = Mth.clamp(Mth.floor(this.y - f2) >> 4, minSection, maxSection); + int minChunkY = Mth.clamp(Mth.floor(this.center.y - f) >> 4, minSection, maxSection);
+ int maxChunkY = Mth.clamp(Mth.floor(this.y + f2) >> 4, minSection, maxSection); + int maxChunkY = Mth.clamp(Mth.floor(this.center.y + f) >> 4, minSection, maxSection);
+ int minChunkZ = Mth.floor(this.z - f2) >> 4; + int minChunkZ = Mth.floor(this.center.z - f) >> 4;
+ int maxChunkZ = Mth.floor(this.z + f2) >> 4; + int maxChunkZ = Mth.floor(this.center.z + f) >> 4;
+
+ ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup entityLookup = this.level.moonrise$getEntityLookup(); + ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup entityLookup = this.level.moonrise$getEntityLookup();
+ for (int chunkX = minChunkX; chunkX <= maxChunkX; ++chunkX) { + for (int chunkX = minChunkX; chunkX <= maxChunkX; ++chunkX) {
+ for (int chunkZ = minChunkZ; chunkZ <= maxChunkZ; ++chunkZ) { + for (int chunkZ = minChunkZ; chunkZ <= maxChunkZ; ++chunkZ) {
@@ -125,28 +111,28 @@ index f696afd7e241bf1966a2d505b5d59bff824b43e4..611fc40fd7461f6d9cd9e737de71e702
+ if (chunk == null) continue; // empty slice + if (chunk == null) continue; // empty slice
+ +
+ for (int chunkY = minChunkY; chunkY <= maxChunkY; ++chunkY) { + for (int chunkY = minChunkY; chunkY <= maxChunkY; ++chunkY) {
+ this.impactEntities(blockCache, blockPos, f2, vec3d, chunk.getSectionEntities(chunkY)); + this.impactEntities(f, chunk.getSectionEntities(chunkY));
+ } + }
+ } + }
+ } + }
+ } + }
+ +
+ protected final void impactEntities(ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[] blockCache, BlockPos.MutableBlockPos blockPos, float f2, Vec3 vec3d, Entity[] entities) { + protected final void impactEntities(float f, Entity[] entities) {
+ for (int i = 0; i < entities.length; i++) { + for (int i = 0; i < entities.length; i++) {
+ Entity entity = entities[i]; + Entity entity = entities[i];
+ if (entity == null) break; // end of entity section + if (entity == null) break; // end of entity section
+ this.impactEntity(blockCache, blockPos, f2, vec3d, entity); + this.impactEntity(f, entity);
+ if (entity != entities[i]) i--; // entities can be removed mid-explosion + if (entity != entities[i]) i--; // entities can be removed mid-explosion
+ } + }
+ } + }
+ +
+ protected final void impactEntity(ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[] blockCache, BlockPos.MutableBlockPos blockPos, float f2, Vec3 vec3d, Entity entity) { + protected final void impactEntity(float f, Entity entity) {
+ if (entity.isAlive() && !entity.isSpectator() && (!this.excludeSourceFromDamage || entity != this.source)) { // Paper - Fix lag from explosions processing dead entities + if (entity.isAlive() && !entity.isSpectator() && (!this.excludeSourceFromDamage || entity != this.source)) { // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source
+ // Sakura end - optimise paper explosions + // Sakura end - optimise paper explosions
if (!entity.ignoreExplosion(this)) {
double d7 = Math.sqrt(entity.distanceToSqr(vec3d)) / (double) f2;
@@ -553,7 +635,7 @@ public class Explosion { if (!entity.ignoreExplosion(this)) {
double d0 = Math.sqrt(entity.distanceToSqr(this.center)) / (double) f;
@@ -508,15 +583,16 @@ public class ServerExplosion implements Explosion {
// - Damaging EntityEnderDragon does nothing // - Damaging EntityEnderDragon does nothing
// - EntityEnderDragon hitbock always covers the other parts and is therefore always present // - EntityEnderDragon hitbock always covers the other parts and is therefore always present
if (entity instanceof EnderDragonPart) { if (entity instanceof EnderDragonPart) {
@@ -155,19 +141,17 @@ index f696afd7e241bf1966a2d505b5d59bff824b43e4..611fc40fd7461f6d9cd9e737de71e702
} }
entity.lastDamageCancelled = false; entity.lastDamageCancelled = false;
@@ -561,9 +643,10 @@ public class Explosion {
seenFraction = (double)this.getBlockDensity(vec3d, entity, blockCache, blockPos); // Paper - optimise collisions
if (entity instanceof EnderDragon) { if (entity instanceof EnderDragon) {
+ AABB bounds = this.getExplosionBounds(f2); // Sakura - optimise paper explosions + AABB bounds = this.getExplosionBounds(f); // Sakura - optimise paper explosions
for (EnderDragonPart entityComplexPart : ((EnderDragon) entity).subEntities) { for (EnderDragonPart entityComplexPart : ((EnderDragon) entity).subEntities) {
// Calculate damage separately for each EntityComplexPart // Calculate damage separately for each EntityComplexPart
- if (list.contains(entityComplexPart)) { - if (list.contains(entityComplexPart)) {
+ if (entityComplexPart.getBoundingBox().intersects(bounds)) { // Sakura - optimise paper explosions + if (entityComplexPart.getBoundingBox().intersects(bounds)) { // Sakura - optimise paper explosions
entityComplexPart.hurt(this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity)); entityComplexPart.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, f2));
} }
} }
@@ -577,7 +660,7 @@ public class Explosion { @@ -525,7 +601,7 @@ public class ServerExplosion implements Explosion {
} }
if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled
@@ -175,16 +159,4 @@ index f696afd7e241bf1966a2d505b5d59bff824b43e4..611fc40fd7461f6d9cd9e737de71e702
+ return; // Sakura - optimise paper explosions + return; // Sakura - optimise paper explosions
} }
// CraftBukkit end // CraftBukkit end
} else { seenFraction = (double)this.getBlockDensity(vec3d, entity, blockCache, blockPos); } // Paper - optimise collisions }
@@ -620,6 +703,11 @@ public class Explosion {
}
}
}
+ // Sakura start - optimise paper explosions
+ }
+
+ protected void clearBlockCache() {
+ // Sakura end - optimise paper explosions
// Paper start - optimise collisions
this.blockCache = null;
this.chunkPosCache = null;

View File

@@ -48,10 +48,10 @@ index 0000000000000000000000000000000000000000..10630c7e04a137ce766f4a45cb0f2e51
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 1927afe8646219403e013c92a6da0a47caf5d7d5..3233e54b6f85ab03859b5a3f2912b7cfb115d050 100644 index 2d8618541d2e673686485901ffc8e693545354a3..4a295091629acd9a540f1194b006f445e4432d4f 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -567,6 +567,25 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -628,6 +628,25 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return flags; return flags;
} }
// Sakura end - load chunks on movement // Sakura end - load chunks on movement
@@ -78,10 +78,10 @@ index 1927afe8646219403e013c92a6da0a47caf5d7d5..3233e54b6f85ab03859b5a3f2912b7cf
public Entity(EntityType<?> type, Level world) { public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet(); 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 diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index c811bc64d0686fdec58defb707d57e539c261b48..0925de100a7da3bba6c3fab7a0c79b2ee0d86904 100644 index b5ce268d1b9d8e57a3927c8e0b91746361fb6778..4696506402ab92439033cf01007fd78a543b5b37 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -1430,6 +1430,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -1499,6 +1499,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
public <T extends Entity> void guardEntityTick(Consumer<T> tickConsumer, T entity) { public <T extends Entity> void guardEntityTick(Consumer<T> tickConsumer, T entity) {
try { try {

View File

@@ -398,30 +398,30 @@ index 0000000000000000000000000000000000000000..2c2a26fdb3081ced574070e5e6f3a1b4
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index d48a1f7d23d1c47465ad8df37facbabe3a15c543..012bec9a32acc26f65c8efbfde341b0d15a4e822 100644 index 873f37587a850fab964c11e96411252fd01e29f9..c871ef194962d1fc574a8d3d9f27dd817ead5fc9 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1822,6 +1822,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1890,6 +1890,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.profiler.pop(); gameprofilerfiller.pop();
worldserver.explosionDensityCache.clear(); // Paper - Optimize explosions gameprofilerfiller.pop();
worldserver.localConfig().expire(currentTick); // Sakura - add local config worldserver.localConfig().expire(currentTick); // Sakura - add local config
+ worldserver.mergeHandler.expire(currentTick); // Sakura - merge cannon entities + worldserver.mergeHandler.expire(currentTick); // Sakura - merge cannon entities
} }
this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index df6074dae80cce98ce27bd28280c246dafa9562a..0a29ad6409226ece40c03c6eba699592c7f0aa11 100644 index ac43d1d91f7ac554f1267b3d76e22bd8f06d8f08..1f278f6ef7e39df676334e7e5853dec4617f6baa 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -714,6 +714,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. @@ -784,6 +784,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
}
org.spigotmc.ActivationRange.activateEntities(this); // Spigot org.spigotmc.ActivationRange.activateEntities(this); // Spigot
this.timings.entityTick.startTiming(); // Spigot
+ Entity[] previousEntity = new Entity[1]; // Sakura - merge cannon entities + Entity[] previousEntity = new Entity[1]; // Sakura - merge cannon entities
this.entityTickList.forEach((entity) -> { this.entityTickList.forEach((entity) -> {
if (!entity.isRemoved()) { if (!entity.isRemoved()) {
if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed if (!tickratemanager.isEntityFrozen(entity)) {
@@ -733,6 +734,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. @@ -801,6 +802,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
entity.stopRiding(); entity.stopRiding();
} }
@@ -438,10 +438,10 @@ index df6074dae80cce98ce27bd28280c246dafa9562a..0a29ad6409226ece40c03c6eba699592
this.guardEntityTick(this::tickNonPassenger, entity); this.guardEntityTick(this::tickNonPassenger, entity);
gameprofilerfiller.pop(); gameprofilerfiller.pop();
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 04ff913f304c7b70b5fcbf866984cb0a91c2b05c..a636c0331b6c963224727eaaed9c09d29ba9d2d7 100644 index 4a295091629acd9a540f1194b006f445e4432d4f..c8b33f6d5b820da4b9e16b7d251ca4aad1875aa8 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -586,6 +586,23 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -647,6 +647,23 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return to.entityState() != null && to.entityState().isCurrentState(this); return to.entityState() != null && to.entityState().isCurrentState(this);
} }
// Sakura end - store entity data/state // Sakura end - store entity data/state
@@ -465,10 +465,10 @@ index 04ff913f304c7b70b5fcbf866984cb0a91c2b05c..a636c0331b6c963224727eaaed9c09d2
public Entity(EntityType<?> type, Level world) { public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet(); this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -4878,6 +4895,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -5209,6 +5226,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
if (this.removalReason != Entity.RemovalReason.UNLOADED_TO_CHUNK) { this.getPassengers().forEach(Entity::stopRiding); } // Paper - rewrite chunk system if (this.removalReason != Entity.RemovalReason.UNLOADED_TO_CHUNK) { this.getPassengers().forEach(Entity::stopRiding); } // Paper - rewrite chunk system
this.levelCallback.onRemove(entity_removalreason); this.levelCallback.onRemove(entity_removalreason);
this.onRemoval(entity_removalreason);
+ // Sakura start - merge cannon entities + // Sakura start - merge cannon entities
+ if (entity_removalreason == RemovalReason.DISCARDED) { + if (entity_removalreason == RemovalReason.DISCARDED) {
+ this.level.mergeHandler.removeEntity(this); + this.level.mergeHandler.removeEntity(this);
@@ -478,7 +478,7 @@ index 04ff913f304c7b70b5fcbf866984cb0a91c2b05c..a636c0331b6c963224727eaaed9c09d2
if (!(this instanceof ServerPlayer) && entity_removalreason != RemovalReason.CHANGED_DIMENSION && !alreadyRemoved) { if (!(this instanceof ServerPlayer) && entity_removalreason != RemovalReason.CHANGED_DIMENSION && !alreadyRemoved) {
// Players need to be special cased, because they are regularly removed from the world // Players need to be special cased, because they are regularly removed from the world
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java 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 0891d4107c9a724522a7abbb6cf61298b18e42a6..53488a1d0c56e7da4cf93c08cab01a033fb4f1f8 100644 index 35d8422ea3bcdc52db6a7f6702fd593346b30c2c..f0617e9d71fa47dfc0566f31d85b8a05ba3b16fc 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -57,7 +57,7 @@ import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -57,7 +57,7 @@ import org.bukkit.craftbukkit.event.CraftEventFactory;
@@ -535,11 +535,11 @@ index 0891d4107c9a724522a7abbb6cf61298b18e42a6..53488a1d0c56e7da4cf93c08cab01a03
+ } + }
+ +
+ @Nullable + @Nullable
+ public ItemEntity spawnAtLocation(ItemLike item) { // may be overridden by plugins + public ItemEntity spawnAtLocation(ServerLevel level, ItemLike item) { // may be overridden by plugins
+ ItemEntity itemEntity = null; + ItemEntity itemEntity = null;
+ +
+ for (int i = 0; i < this.mergeData.getCount(); ++i) { + for (int i = 0; i < this.mergeData.getCount(); ++i) {
+ itemEntity = super.spawnAtLocation(item); + itemEntity = super.spawnAtLocation(level, item);
+ } + }
+ +
+ return itemEntity; + return itemEntity;
@@ -557,15 +557,15 @@ index 0891d4107c9a724522a7abbb6cf61298b18e42a6..53488a1d0c56e7da4cf93c08cab01a03
} }
public FallingBlockEntity(Level world, double x, double y, double z, BlockState block) { public FallingBlockEntity(Level world, double x, double y, double z, BlockState block) {
@@ -207,6 +260,7 @@ public class FallingBlockEntity extends Entity { @@ -222,6 +275,7 @@ public class FallingBlockEntity extends Entity {
return; return;
} }
// CraftBukkit end // CraftBukkit end
+ if (this.respawnEntity()) return; // Sakura - merge cannon entities + if (this.respawnEntity()) return; // Sakura - merge cannon entities
if (this.level().setBlock(blockposition, this.blockState, 3)) { if (this.level().setBlock(blockposition, this.blockState, 3)) {
((ServerLevel) this.level()).getChunkSource().chunkMap.broadcast(this, new ClientboundBlockUpdatePacket(blockposition, this.level().getBlockState(blockposition))); ((ServerLevel) this.level()).getChunkSource().chunkMap.broadcast(this, new ClientboundBlockUpdatePacket(blockposition, this.level().getBlockState(blockposition)));
this.discard(EntityRemoveEvent.Cause.DESPAWN); this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
@@ -326,6 +380,7 @@ public class FallingBlockEntity extends Entity { @@ -342,6 +396,7 @@ public class FallingBlockEntity extends Entity {
nbt.putBoolean("CancelDrop", this.cancelDrop); nbt.putBoolean("CancelDrop", this.cancelDrop);
if (!autoExpire) {nbt.putBoolean("Paper.AutoExpire", false);} // Paper - Expand FallingBlock API if (!autoExpire) {nbt.putBoolean("Paper.AutoExpire", false);} // Paper - Expand FallingBlock API
@@ -573,7 +573,7 @@ index 0891d4107c9a724522a7abbb6cf61298b18e42a6..53488a1d0c56e7da4cf93c08cab01a03
} }
@Override @Override
@@ -358,6 +413,11 @@ public class FallingBlockEntity extends Entity { @@ -374,6 +429,11 @@ public class FallingBlockEntity extends Entity {
this.autoExpire = nbt.getBoolean("Paper.AutoExpire"); this.autoExpire = nbt.getBoolean("Paper.AutoExpire");
} }
// Paper end - Expand FallingBlock API // Paper end - Expand FallingBlock API
@@ -586,10 +586,10 @@ index 0891d4107c9a724522a7abbb6cf61298b18e42a6..53488a1d0c56e7da4cf93c08cab01a03
public void setHurtsEntities(float fallHurtAmount, int fallHurtMax) { public void setHurtsEntities(float fallHurtAmount, int fallHurtMax) {
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java 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 888d018a8e73234332455b7d3700e70e1a50c5db..a8e540c8a27135336fb2d6e37aec13d598b2000e 100644 index 25a25b5c6497c9823a41e6bd8fd22f0841377c62..6b739e820af6333c1ff3a4b87154d4c00c9a5559 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -30,7 +30,7 @@ import org.bukkit.event.entity.EntityRemoveEvent; @@ -33,7 +33,7 @@ import org.bukkit.event.entity.EntityRemoveEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent;
// CraftBukkit end // CraftBukkit end
@@ -598,8 +598,8 @@ index 888d018a8e73234332455b7d3700e70e1a50c5db..a8e540c8a27135336fb2d6e37aec13d5
private static final EntityDataAccessor<Integer> DATA_FUSE_ID = SynchedEntityData.defineId(PrimedTnt.class, EntityDataSerializers.INT); private static final EntityDataAccessor<Integer> DATA_FUSE_ID = SynchedEntityData.defineId(PrimedTnt.class, EntityDataSerializers.INT);
private static final EntityDataAccessor<BlockState> DATA_BLOCK_STATE_ID = SynchedEntityData.defineId(PrimedTnt.class, EntityDataSerializers.BLOCK_STATE); private static final EntityDataAccessor<BlockState> DATA_BLOCK_STATE_ID = SynchedEntityData.defineId(PrimedTnt.class, EntityDataSerializers.BLOCK_STATE);
@@ -54,11 +54,48 @@ public class PrimedTnt extends Entity implements TraceableEntity { @@ -59,12 +59,49 @@ public class PrimedTnt extends Entity implements TraceableEntity {
public float yield = 4; // CraftBukkit - add field public float explosionPower;
public boolean isIncendiary = false; // CraftBukkit - add field public boolean isIncendiary = false; // CraftBukkit - add field
+ // Sakura start - merge cannon entities + // Sakura start - merge cannon entities
@@ -640,6 +640,7 @@ index 888d018a8e73234332455b7d3700e70e1a50c5db..a8e540c8a27135336fb2d6e37aec13d5
+ +
public PrimedTnt(EntityType<? extends PrimedTnt> type, Level world) { public PrimedTnt(EntityType<? extends PrimedTnt> type, Level world) {
super(type, world); super(type, world);
this.explosionPower = 4.0F;
this.blocksBuilding = true; this.blocksBuilding = true;
this.isPrimedTNT = true; // Sakura this.isPrimedTNT = true; // Sakura
this.loadChunks = world.sakuraConfig().cannons.loadChunks; // Sakura - load chunks on movement this.loadChunks = world.sakuraConfig().cannons.loadChunks; // Sakura - load chunks on movement
@@ -647,7 +648,7 @@ index 888d018a8e73234332455b7d3700e70e1a50c5db..a8e540c8a27135336fb2d6e37aec13d5
} }
public PrimedTnt(Level world, double x, double y, double z, @Nullable LivingEntity igniter) { public PrimedTnt(Level world, double x, double y, double z, @Nullable LivingEntity igniter) {
@@ -118,6 +155,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { @@ -125,6 +162,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
if (i <= 0) { 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 // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event
// this.discard(); // this.discard();
@@ -655,15 +656,16 @@ index 888d018a8e73234332455b7d3700e70e1a50c5db..a8e540c8a27135336fb2d6e37aec13d5
if (!this.level().isClientSide) { if (!this.level().isClientSide) {
this.explode(); this.explode();
} }
@@ -176,6 +214,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { @@ -185,7 +223,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
protected void addAdditionalSaveData(CompoundTag nbt) { if (this.explosionPower != 4.0F) {
nbt.putShort("fuse", (short) this.getFuse()); nbt.putFloat("explosion_power", this.explosionPower);
nbt.put("block_state", NbtUtils.writeBlockState(this.getBlockState())); }
-
+ nbt.putInt("merge_count", this.mergeData.getCount()); // Sakura - merge cannon entities + nbt.putInt("merge_count", this.mergeData.getCount()); // Sakura - merge cannon entities
} }
@Override @Override
@@ -184,6 +223,11 @@ public class PrimedTnt extends Entity implements TraceableEntity { @@ -194,6 +232,11 @@ public class PrimedTnt extends Entity implements TraceableEntity {
if (nbt.contains("block_state", 10)) { if (nbt.contains("block_state", 10)) {
this.setBlockState(NbtUtils.readBlockState(this.level().holderLookup(Registries.BLOCK), nbt.getCompound("block_state"))); this.setBlockState(NbtUtils.readBlockState(this.level().holderLookup(Registries.BLOCK), nbt.getCompound("block_state")));
} }
@@ -673,22 +675,22 @@ index 888d018a8e73234332455b7d3700e70e1a50c5db..a8e540c8a27135336fb2d6e37aec13d5
+ } + }
+ // Sakura end - merge cannon entities + // Sakura end - merge cannon entities
} if (nbt.contains("explosion_power", 99)) {
this.explosionPower = Mth.clamp(nbt.getFloat("explosion_power"), 0.0F, 128.0F);
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 0a0884ceb365e01432126b414335c1ff8fa8e084..dc2b8e054a3dd89e1c45d0c96ad640a7d32a2c0d 100644 index 4696506402ab92439033cf01007fd78a543b5b37..d036cdcc17b8429c986946a020cb34cd6ced322e 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -695,6 +695,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -841,6 +841,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
return chunk != null ? chunk.getNoiseBiome(x, y, z) : this.getUncachedNoiseBiome(x, y, z); return chunk != null ? chunk.getNoiseBiome(x, y, z) : this.getUncachedNoiseBiome(x, y, z);
} }
// Paper end - optimise random ticking // Paper end - optimise random ticking
+ public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities + public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities
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 - sakura configuration files// Paper - create paper world config & Anti-Xray protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, 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, java.util.function.Supplier<me.samsuik.sakura.configuration.WorldConfiguration> sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura - sakura configuration files // Paper - create paper world config & Anti-Xray
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot // Paper start - getblock optimisations - cache world height/sections
diff --git a/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java
index 8b33e35c843e5c0b8988a2ef2a38a2673035292f..1aa36b456b1c635d3184aeab70d1d84266e22c4b 100644 index 9afa811579ac2e556b5c5c23b3b49587439dfadc..c2eb63de04fc48bd2cc1aad8d9cba272c0829c80 100644
--- a/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java --- a/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java
@@ -89,7 +89,7 @@ public abstract class BasePressurePlateBlock extends Block { @@ -89,7 +89,7 @@ public abstract class BasePressurePlateBlock extends Block {
@@ -772,7 +774,7 @@ index 1359d25a32b4a5d5e8e68ce737bd19f7b5afaf69..55f67c2ca07eca0d3e1522eebbb4ce37
public FallingBlockEntity getHandle() { public FallingBlockEntity getHandle() {
return (FallingBlockEntity) this.entity; return (FallingBlockEntity) this.entity;
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
index dac3d34677688ac560bc1be2087a08479ef71b87..e71eb9e68c3b3c433a3fe4dfbe65f60214d6c225 100644 index a61aec087fa7cec27a803668bdc1b9e6eb336755..c6f36ab2368d0e2e4555d5f8edc0132dcb61a53c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
+++ b/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 { @@ -12,6 +12,28 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed {
@@ -803,4 +805,4 @@ index dac3d34677688ac560bc1be2087a08479ef71b87..e71eb9e68c3b3c433a3fe4dfbe65f602
+ +
@Override @Override
public float getYield() { public float getYield() {
return this.getHandle().yield; return this.getHandle().explosionPower;

View File

@@ -126,23 +126,35 @@ index 0000000000000000000000000000000000000000..d7e24638f07f243502004970ab4ce646
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 012bec9a32acc26f65c8efbfde341b0d15a4e822..8041737aa751bec1c51ee3d9dacd6dfb2b845265 100644 index c871ef194962d1fc574a8d3d9f27dd817ead5fc9..31dd38d80c648e3f946c123878529b3393be5a91 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1823,6 +1823,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1891,6 +1891,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
worldserver.explosionDensityCache.clear(); // Paper - Optimize explosions gameprofilerfiller.pop();
worldserver.localConfig().expire(currentTick); // Sakura - add local config worldserver.localConfig().expire(currentTick); // Sakura - add local config
worldserver.mergeHandler.expire(currentTick); // Sakura - merge cannon entities worldserver.mergeHandler.expire(currentTick); // Sakura - merge cannon entities
+ worldserver.densityCache.invalidate(); // Sakura - explosion density cache + worldserver.densityCache.invalidate(); // Sakura - explosion density cache
} }
this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 611fc40fd7461f6d9cd9e737de71e702bf1f36c5..d8baaed4ae55c079bdfd684b6d942923dfbbbcd1 100644 index d036cdcc17b8429c986946a020cb34cd6ced322e..b45ad0125cd5c116126e8ffb893585970ea3b960 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -306,7 +306,12 @@ public class Explosion { @@ -842,6 +842,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
Math.fma(dz, diffZ, offZ) }
// Paper end - optimise random ticking
public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities
+ public final me.samsuik.sakura.explosion.density.BlockDensityCache densityCache = new me.samsuik.sakura.explosion.density.BlockDensityCache(); // Sakura - explosion density cache
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, 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, java.util.function.Supplier<me.samsuik.sakura.configuration.WorldConfiguration> sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura - sakura configuration files // Paper - create paper world config & Anti-Xray
// Paper start - getblock optimisations - cache world height/sections
diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java
index a92be80081178cc302a7f0b646bad7daa28f7c66..10432b31acd047ac2aa8581f2ee863254ec8d1eb 100644
--- a/src/main/java/net/minecraft/world/level/ServerExplosion.java
+++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java
@@ -297,7 +297,12 @@ public class ServerExplosion implements Explosion {
Math.fma(dz, diffZ, offZ)
); );
- if (!this.clipsAnything(from, source, context, blockCache, blockPos)) { - if (!this.clipsAnything(from, source, context, blockCache, blockPos)) {
@@ -155,71 +167,59 @@ index 611fc40fd7461f6d9cd9e737de71e702bf1f36c5..d8baaed4ae55c079bdfd684b6d942923
++missedRays; ++missedRays;
} }
} }
@@ -412,7 +417,16 @@ public class Explosion { @@ -377,7 +382,16 @@ public class ServerExplosion implements Explosion {
double d10 = Mth.lerp(d7, axisalignedbb.minZ, axisalignedbb.maxZ); double d10 = Mth.lerp(d7, axisalignedbb.minZ, axisalignedbb.maxZ);
Vec3 vec3d1 = new Vec3(d8 + d3, d9, d10 + d4); 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, pos, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType() == HitResult.Type.MISS) {
+ // Sakura start - replace density cache + // Sakura start - replace density cache
+ final net.minecraft.world.phys.HitResult.Type hitResult; + final net.minecraft.world.phys.HitResult.Type hitResult;
+ final float density = entity.level().densityCache.getKnownDensity(vec3d1); + final float density = entity.level().densityCache.getKnownDensity(vec3d1);
+ if (density != me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) { + if (density != me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) {
+ hitResult = density != 0.0f ? net.minecraft.world.phys.HitResult.Type.MISS : net.minecraft.world.phys.HitResult.Type.BLOCK; + hitResult = density != 0.0f ? net.minecraft.world.phys.HitResult.Type.MISS : net.minecraft.world.phys.HitResult.Type.BLOCK;
+ } else { + } else {
+ hitResult = entity.level().clip(new ClipContext(vec3d1, source, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType(); + hitResult = entity.level().clip(new ClipContext(vec3d1, pos, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType();
+ } + }
+ if (hitResult == HitResult.Type.MISS) { + if (hitResult == HitResult.Type.MISS) {
+ // Sakura end - replace density cache + // Sakura end - replace density cache
++i; ++i;
} }
@@ -802,6 +816,11 @@ public class Explosion { @@ -691,6 +705,12 @@ public class ServerExplosion implements Explosion {
}); return;
} }
// CraftBukkit end
+ // Sakura start - explosion density cache
+ if (!positions.isEmpty() && !this.level.paperConfig().environment.optimizeExplosions) {
+ this.level.densityCache.invalidate();
+ }
+ // Sakura end - explosion density cache
+
Iterator iterator = positions.iterator();
+ // Sakura start - explosion density cache while (iterator.hasNext()) {
+ if (!this.toBlow.isEmpty() && !this.level.paperConfig().environment.optimizeExplosions) { @@ -864,14 +884,12 @@ public class ServerExplosion implements Explosion {
+ this.level.densityCache.invalidate();
+ }
+ // Sakura end - explosion density cache
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
@@ -930,14 +949,12 @@ public class Explosion {
}
// Paper start - Optimize explosions // Paper start - Optimize explosions
private float getBlockDensity(Vec3 vec3d, Entity entity, ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[] blockCache, BlockPos.MutableBlockPos blockPos) { // Paper - optimise collisions private float getBlockDensity(Vec3 vec3d, Entity entity) {
- if (!this.level.paperConfig().environment.optimizeExplosions) { - if (!this.level.paperConfig().environment.optimizeExplosions) {
- return this.getSeenFraction(vec3d, entity, blockCache, blockPos); // Paper - optimise collisions - return this.getSeenFraction(vec3d, entity, this.directMappedBlockCache, this.mutablePos); // Paper - collision optimisations
- } - }
- CacheKey key = new CacheKey(this, entity.getBoundingBox()); - CacheKey key = new CacheKey(this, entity.getBoundingBox());
- Float blockDensity = this.level.explosionDensityCache.get(key); - Float blockDensity = this.level.explosionDensityCache.get(key);
- if (blockDensity == null) { - if (blockDensity == null) {
- blockDensity = this.getSeenFraction(vec3d, entity, blockCache, blockPos); // Paper - optimise collisions
- this.level.explosionDensityCache.put(key, blockDensity);
+ // Sakura start - replace density cache + // Sakura start - replace density cache
+ float blockDensity = this.level.densityCache.getDensity(vec3d, entity); + float blockDensity = this.level.densityCache.getDensity(vec3d, entity);
+ if (blockDensity == me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) { + if (blockDensity == me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) {
+ blockDensity = this.getSeenFraction(vec3d, entity, blockCache, blockPos); // Paper - optimise explosions; blockDensity = this.getSeenFraction(vec3d, entity, this.directMappedBlockCache, this.mutablePos); // Paper - collision optimisations
- this.level.explosionDensityCache.put(key, blockDensity);
+ this.level.densityCache.putDensity(vec3d, entity, blockDensity); + this.level.densityCache.putDensity(vec3d, entity, blockDensity);
+ // Sakura end - replace density cache + // Sakura end - replace density cache
} }
return blockDensity; return blockDensity;
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index dc2b8e054a3dd89e1c45d0c96ad640a7d32a2c0d..ed049df61d38ed06076273115b841e2852963844 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -696,6 +696,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
}
// Paper end - optimise random ticking
public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities
+ public final me.samsuik.sakura.explosion.density.BlockDensityCache densityCache = new me.samsuik.sakura.explosion.density.BlockDensityCache(); // Sakura - explosion density cache
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 - sakura configuration files// Paper - create paper world config & Anti-Xray
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/BasePressurePlateBlock.java b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java
index 1aa36b456b1c635d3184aeab70d1d84266e22c4b..afb76b13f404a12a5f5b9ffe72756d31290a9a85 100644 index c2eb63de04fc48bd2cc1aad8d9cba272c0829c80..0d9f944a3777ac3a0f569832468c5c97b0fdf488 100644
--- a/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java --- a/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java
@@ -109,6 +109,11 @@ public abstract class BasePressurePlateBlock extends Block { @@ -109,6 +109,11 @@ public abstract class BasePressurePlateBlock extends Block {
@@ -235,10 +235,10 @@ index 1aa36b456b1c635d3184aeab70d1d84266e22c4b..afb76b13f404a12a5f5b9ffe72756d31
this.updateNeighbours(world, pos); this.updateNeighbours(world, pos);
world.setBlocksDirty(pos, state, iblockdata1); world.setBlocksDirty(pos, state, iblockdata1);
diff --git a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
index 76aca266d3f3222502ff4c196228f08fcd88c5f8..b965d1b38a0a3f08531060039e46913dff3bfd0e 100644 index c2589f42c467ca672417c24076313da51bb2dcbb..5ae5ef6edf3a6e2b8be9ce11ca46c7714accc4f3 100644
--- a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java --- a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java +++ b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
@@ -173,6 +173,11 @@ public class TripWireHookBlock extends Block { @@ -175,6 +175,11 @@ public class TripWireHookBlock extends Block {
blockposition1 = pos.relative(enumdirection, j); blockposition1 = pos.relative(enumdirection, j);
Direction enumdirection1 = enumdirection.getOpposite(); Direction enumdirection1 = enumdirection.getOpposite();
@@ -251,10 +251,10 @@ index 76aca266d3f3222502ff4c196228f08fcd88c5f8..b965d1b38a0a3f08531060039e46913d
TripWireHookBlock.notifyNeighbors(block, world, blockposition1, enumdirection1); TripWireHookBlock.notifyNeighbors(block, world, blockposition1, enumdirection1);
TripWireHookBlock.emitState(world, blockposition1, flag4, flag5, flag2, flag3); TripWireHookBlock.emitState(world, blockposition1, flag4, flag5, flag2, flag3);
diff --git a/src/main/java/net/minecraft/world/phys/AABB.java b/src/main/java/net/minecraft/world/phys/AABB.java diff --git a/src/main/java/net/minecraft/world/phys/AABB.java b/src/main/java/net/minecraft/world/phys/AABB.java
index 29123f3a2f211c08d1a9ccf62ca9bc9822f90111..a63bd7945eef572615b1aa4a4914fa385b25cad2 100644 index 6cf6d4ec7b9e43c7b2b4c0e2fb080964ff588130..a867ec0347038c7246af3f3377eceda17e695ec3 100644
--- a/src/main/java/net/minecraft/world/phys/AABB.java --- a/src/main/java/net/minecraft/world/phys/AABB.java
+++ b/src/main/java/net/minecraft/world/phys/AABB.java +++ b/src/main/java/net/minecraft/world/phys/AABB.java
@@ -508,4 +508,28 @@ public class AABB { @@ -551,4 +551,28 @@ public class AABB {
public static AABB ofSize(Vec3 center, double dx, double dy, double dz) { public static AABB ofSize(Vec3 center, double dx, double dy, double dz) {
return new AABB(center.x - dx / 2.0, center.y - dy / 2.0, center.z - dz / 2.0, center.x + dx / 2.0, center.y + dy / 2.0, center.z + dz / 2.0); return new AABB(center.x - dx / 2.0, center.y - dy / 2.0, center.z - dz / 2.0, center.x + dx / 2.0, center.y + dy / 2.0, center.z + dz / 2.0);
} }

View File

@@ -4,11 +4,11 @@ Date: Fri, 3 May 2024 15:18:58 +0100
Subject: [PATCH] Optimise explosions in protected regions Subject: [PATCH] Optimise explosions in protected regions
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java
index d8baaed4ae55c079bdfd684b6d942923dfbbbcd1..220d97947df493d1ab825e6637ca648e0b186d18 100644 index 10432b31acd047ac2aa8581f2ee863254ec8d1eb..6001583d054b9690e34b6878b1298d93e6552a2a 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java --- a/src/main/java/net/minecraft/world/level/ServerExplosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java
@@ -354,6 +354,22 @@ public class Explosion { @@ -345,6 +345,22 @@ public class ServerExplosion implements Explosion {
return rays; return rays;
} }
// Sakura end - optimise paper explosions // Sakura end - optimise paper explosions
@@ -18,7 +18,7 @@ index d8baaed4ae55c079bdfd684b6d942923dfbbbcd1..220d97947df493d1ab825e6637ca648e
+ // It tells us if the result was thrown away, so we can avoid the block searching logic. + // It tells us if the result was thrown away, so we can avoid the block searching logic.
+ // As a side effect the event is called twice which may interfere with some plugins. + // As a side effect the event is called twice which may interfere with some plugins.
+ if (this.source != null && this.level.sakuraConfig().cannons.explosion.optimiseProtectedRegions) { + if (this.source != null && this.level.sakuraConfig().cannons.explosion.optimiseProtectedRegions) {
+ Location location = new Location(this.level.getWorld(), this.x, this.y, this.z); + Location location = new Location(this.level.getWorld(), this.center.x, this.center.y, this.center.z);
+ List<org.bukkit.block.Block> blocks = new ObjectArrayList<>(1); + List<org.bukkit.block.Block> blocks = new ObjectArrayList<>(1);
+ blocks.add(location.getBlock()); + blocks.add(location.getBlock());
+ EntityExplodeEvent event = CraftEventFactory.callEntityExplodeEvent(this.source, blocks, 0.0f, this.blockInteraction); + EntityExplodeEvent event = CraftEventFactory.callEntityExplodeEvent(this.source, blocks, 0.0f, this.blockInteraction);
@@ -29,14 +29,17 @@ index d8baaed4ae55c079bdfd684b6d942923dfbbbcd1..220d97947df493d1ab825e6637ca648e
+ } + }
+ // Sakura end - optimise explosion protected regions + // Sakura end - optimise explosion protected regions
public static DamageSource getDefaultDamageSource(Level world, @Nullable Entity source) { public ServerExplosion(ServerLevel world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, Vec3 pos, float power, boolean createFire, Explosion.BlockInteraction destructionType) {
return world.damageSources().explosion(source, Explosion.getIndirectSourceEntityInternal(source)); this.level = world;
@@ -487,7 +503,7 @@ public class Explosion { @@ -441,6 +457,11 @@ public class ServerExplosion implements Explosion {
return ret;
// Paper start - collision optimisations
// Sakura start - optimise paper explosions
- if (initialCache.resistance <= (this.radius * 1.3f) && this.interactsWithBlocks()) {
+ if (initialCache.resistance <= (this.radius * 1.3f) && this.interactsWithBlocks() && this.isRegionUnprotected()) { // Sakura - optimise protected explosions
this.searchForBlocks(blockCache, initialCache);
} }
this.locateAndImpactEntities(blockCache); // Sakura end - optimise paper explosions
+ // Sakura start - optimise protected explosions
+ if (this.isRegionUnprotected()) {
+ return ret;
+ }
+ // Sakura end - optimise protected explosions
// only ~1/3rd of the loop iterations in vanilla will result in a ray, as it is iterating the perimeter of
// a 16x16x16 cube

View File

@@ -23,28 +23,23 @@ index c21e00812f1aaa1279834a0562d360d6b89e146c..1e1329adde1457898a3002279b53b1bb
if (index >= 0) { if (index >= 0) {
diff --git a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java diff --git a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..86a4b9502df49b1614fc76920b164e1148244643 index 0000000000000000000000000000000000000000..4cbef703a70208191d13075c2c54581eb8239f70
--- /dev/null --- /dev/null
+++ b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java +++ b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java
@@ -0,0 +1,222 @@ @@ -0,0 +1,206 @@
+package me.samsuik.sakura.explosion.special; +package me.samsuik.sakura.explosion.special;
+ +
+import ca.spottedleaf.moonrise.common.util.WorldUtil; +import ca.spottedleaf.moonrise.common.util.WorldUtil;
+import ca.spottedleaf.moonrise.patches.chunk_system.level.entity.ChunkEntitySlices; +import ca.spottedleaf.moonrise.patches.chunk_system.level.entity.ChunkEntitySlices;
+import ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup; +import ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup;
+import ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache;
+import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos;
+import net.minecraft.core.Holder;
+import net.minecraft.core.particles.ParticleOptions;
+import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerLevel;
+import net.minecraft.sounds.SoundEvent;
+import net.minecraft.util.Mth; +import net.minecraft.util.Mth;
+import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.damagesource.DamageSource;
+import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.item.PrimedTnt; +import net.minecraft.world.entity.item.PrimedTnt;
+import net.minecraft.world.level.Explosion;
+import net.minecraft.world.level.ExplosionDamageCalculator; +import net.minecraft.world.level.ExplosionDamageCalculator;
+import net.minecraft.world.level.Level; +import net.minecraft.world.level.ServerExplosion;
+import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.AABB;
+import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.Vec3;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
@@ -52,22 +47,19 @@ index 0000000000000000000000000000000000000000..86a4b9502df49b1614fc76920b164e11
+import java.util.List; +import java.util.List;
+import java.util.function.Consumer; +import java.util.function.Consumer;
+ +
+public abstract class SpecialisedExplosion<T extends Entity> extends Explosion { +public abstract class SpecialisedExplosion<T extends Entity> extends ServerExplosion {
+ private static final double ENTITY_DISPATCH_DISTANCE = Math.pow(32.0, 2.0); + private static final double ENTITY_DISPATCH_DISTANCE = Math.pow(32.0, 2.0);
+ +
+ protected final ServerLevel level;
+ protected Vec3 position;
+ protected final T cause; // preferred over source + protected final T cause; // preferred over source
+ private Vec3 impactPosition; + private Vec3 impactPosition;
+ protected ExplosionBlockCache[] recentBlockCache;
+ protected final BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos(); + protected final BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos();
+ private final Consumer<SpecialisedExplosion<T>> applyEffects;
+ +
+ public SpecialisedExplosion(Level world, T entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, BlockInteraction destructionType, ParticleOptions particle, ParticleOptions emitterParticle, Holder<SoundEvent> soundEvent) { + public SpecialisedExplosion(ServerLevel level, T entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, Vec3 center, float power, boolean createFire, BlockInteraction destructionType, Consumer<SpecialisedExplosion<T>> applyEffects) {
+ super(world, entity, damageSource, behavior, x, y, z, power, createFire, destructionType, particle, emitterParticle, soundEvent); + super(level, entity, damageSource, behavior, center, power, createFire, destructionType);
+ this.level = (ServerLevel) world;
+ this.position = new Vec3(x, y, z);
+ this.cause = entity; + this.cause = entity;
+ this.impactPosition = this.position; + this.impactPosition = center;
+ this.applyEffects = applyEffects;
+ } + }
+ +
+ protected double getExplosionOffset() { + protected double getExplosionOffset() {
@@ -79,48 +71,40 @@ index 0000000000000000000000000000000000000000..86a4b9502df49b1614fc76920b164e11
+ protected abstract void startExplosion(); + protected abstract void startExplosion();
+ +
+ @Override + @Override
+ protected final void clearBlockCache() {
+ super.clearBlockCache();
+ this.recentBlockCache = null;
+ }
+
+ @Override
+ @Deprecated
+ public final void explode() { + public final void explode() {
+ if (this.radius() < 0.1F) { + if (this.radius() < 0.1F) {
+ // (radius < 0.1F) in bukkit is assumed to not be able to find any blocks or entities. + // (radius < 0.1F) in bukkit is assumed to not be able to find any blocks or entities.
+ for (int i = 1; i < this.getExplosionCount(); ++i) { + for (int i = 1; i < this.getExplosionCount(); ++i) {
+ this.finalizeExplosionAndParticles(); + this.finalizeExplosionAndParticles(List.of());
+ } + }
+ } else { + } else {
+ this.recentBlockCache = this.createBlockCache(); + this.createBlockCache();
+ this.startExplosion(); // search for blocks, impact entities, finalise if necessary + this.startExplosion(); // search for blocks, impact entities, finalise if necessary
+ this.clearBlockCache(); + this.clearBlockCache();
+ } + }
+ } + }
+ +
+ protected final boolean requiresImpactEntities() { + protected final boolean requiresImpactEntities(List<BlockPos> blocks, Vec3 center) {
+ if (this.impactPosition.distanceToSqr(this.position) > ENTITY_DISPATCH_DISTANCE) { + if (this.impactPosition.distanceToSqr(center) > ENTITY_DISPATCH_DISTANCE) {
+ this.impactPosition = this.position; + this.impactPosition = center;
+ return true; + return true;
+ } + }
+ return !this.getToBlow().isEmpty(); + return !blocks.isEmpty();
+ } + }
+ +
+ protected final boolean finalizeExplosionAndParticles() { + protected final boolean finalizeExplosionAndParticles(List<BlockPos> blocks) {
+ this.wasCanceled = false; + this.wasCanceled = false;
+ super.finalizeExplosion(false); + this.interactWithBlocks(blocks);
+ boolean destroyedBlocks = !this.getToBlow().isEmpty(); + boolean destroyedBlocks = !blocks.isEmpty();
+ +
+ if (!this.interactsWithBlocks()) { + if (!this.interactsWithBlocks()) {
+ this.getToBlow().clear(); // server sends block changes in the explosion packet + blocks.clear(); // server sends block changes in the explosion packet
+ } + }
+ +
+ if (!this.wasCanceled) { + if (!this.wasCanceled) {
+ this.level.notifyPlayersOfExplosion(this.x, this.y, this.z, this.radius(), this); + this.applyEffects.accept(this);
+ } + }
+ +
+ this.getToBlow().clear();
+ return destroyedBlocks; + return destroyedBlocks;
+ } + }
+ +
@@ -129,13 +113,13 @@ index 0000000000000000000000000000000000000000..86a4b9502df49b1614fc76920b164e11
+ // This can help reduce block retrievals while block searching when there's a durable block, + // This can help reduce block retrievals while block searching when there's a durable block,
+ // and when ray tracing for obstructions. This is disabled by default because plugins can + // and when ray tracing for obstructions. This is disabled by default because plugins can
+ // change blocks in the explosion event. + // change blocks in the explosion event.
+ if (this.level.sakuraConfig().cannons.explosion.useBlockCacheAcrossExplosions && !foundBlocks.isEmpty() && !destroyedBlocks) { + if (this.level().sakuraConfig().cannons.explosion.useBlockCacheAcrossExplosions && !foundBlocks.isEmpty() && !destroyedBlocks) {
+ this.markBlocksInCacheAsExplodable(foundBlocks); + this.markBlocksInCacheAsExplodable(foundBlocks);
+ } else { + } else {
+ super.blockCache.clear(); + super.blockCache.clear();
+ } + }
+ +
+ java.util.Arrays.fill(this.recentBlockCache, null); + java.util.Arrays.fill(this.directMappedBlockCache, null);
+ } + }
+ +
+ protected final void recalculateExplosionPosition() { + protected final void recalculateExplosionPosition() {
@@ -143,15 +127,15 @@ index 0000000000000000000000000000000000000000..86a4b9502df49b1614fc76920b164e11
+ } + }
+ +
+ protected final void recalculateExplosionPosition(T entity) { + protected final void recalculateExplosionPosition(T entity) {
+ this.x = entity.getX(); + double x = entity.getX();
+ this.y = entity.getY() + this.getExplosionOffset(); + double y = entity.getY() + this.getExplosionOffset();
+ this.z = entity.getZ(); + double z = entity.getZ();
+ this.position = new Vec3(this.x, this.y, this.z); + this.center = new Vec3(x, y, z);
+ } + }
+ +
+ protected final void forEachEntitySliceInBounds(AABB bb, Consumer<Entity[]> sliceConsumer) { + protected final void forEachEntitySliceInBounds(AABB bb, Consumer<Entity[]> sliceConsumer) {
+ int minSection = WorldUtil.getMinSection(this.level); + int minSection = WorldUtil.getMinSection(this.level());
+ int maxSection = WorldUtil.getMaxSection(this.level); + int maxSection = WorldUtil.getMaxSection(this.level());
+ +
+ int minChunkX = Mth.floor(bb.minX) >> 4; + int minChunkX = Mth.floor(bb.minX) >> 4;
+ int minChunkY = Mth.clamp(Mth.floor(bb.minY) >> 4, minSection, maxSection); + int minChunkY = Mth.clamp(Mth.floor(bb.minY) >> 4, minSection, maxSection);
@@ -160,7 +144,7 @@ index 0000000000000000000000000000000000000000..86a4b9502df49b1614fc76920b164e11
+ int maxChunkY = Mth.clamp(Mth.floor(bb.maxY) >> 4, minSection, maxSection); + int maxChunkY = Mth.clamp(Mth.floor(bb.maxY) >> 4, minSection, maxSection);
+ int maxChunkZ = Mth.floor(bb.maxZ) >> 4; + int maxChunkZ = Mth.floor(bb.maxZ) >> 4;
+ +
+ EntityLookup entityLookup = this.level.moonrise$getEntityLookup(); + EntityLookup entityLookup = this.level().moonrise$getEntityLookup();
+ for (int chunkX = minChunkX; chunkX <= maxChunkX; ++chunkX) { + for (int chunkX = minChunkX; chunkX <= maxChunkX; ++chunkX) {
+ for (int chunkZ = minChunkZ; chunkZ <= maxChunkZ; ++chunkZ) { + for (int chunkZ = minChunkZ; chunkZ <= maxChunkZ; ++chunkZ) {
+ ChunkEntitySlices chunk = entityLookup.getChunk(chunkX, chunkZ); + ChunkEntitySlices chunk = entityLookup.getChunk(chunkX, chunkZ);
@@ -199,7 +183,7 @@ index 0000000000000000000000000000000000000000..86a4b9502df49b1614fc76920b164e11
+ this.impactCannonEntity(entity, pos, potential, radius); + this.impactCannonEntity(entity, pos, potential, radius);
+ } else { + } else {
+ for (int i = 0; i < potential; ++i) { + for (int i = 0; i < potential; ++i) {
+ super.impactEntity(this.recentBlockCache, this.mutablePos, (float) radius, pos, entity); + super.impactEntity((float) radius, entity);
+ } + }
+ } + }
+ } + }
@@ -217,7 +201,7 @@ index 0000000000000000000000000000000000000000..86a4b9502df49b1614fc76920b164e11
+ x /= distance; + x /= distance;
+ y /= distance; + y /= distance;
+ z /= distance; + z /= distance;
+ double density = this.getBlockDensity(pos, entity, this.recentBlockCache, this.mutablePos); // Paper - Optimize explosions // Paper - optimise explosions + double density = this.getBlockDensity(pos, entity); // Paper - Optimize explosions
+ double exposure = (1.0D - distanceFromBottom) * density; + double exposure = (1.0D - distanceFromBottom) * density;
+ +
+ if (exposure == 0.0) { + if (exposure == 0.0) {
@@ -251,10 +235,10 @@ index 0000000000000000000000000000000000000000..86a4b9502df49b1614fc76920b164e11
+} +}
diff --git a/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java b/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java diff --git a/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java b/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..a5d13c6b0d8765e4a65b43f5835fd907738e1da4 index 0000000000000000000000000000000000000000..d5bd783cca91ab292cd9957fe25803773f75c4ee
--- /dev/null --- /dev/null
+++ b/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java +++ b/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java
@@ -0,0 +1,207 @@ @@ -0,0 +1,208 @@
+package me.samsuik.sakura.explosion.special; +package me.samsuik.sakura.explosion.special;
+ +
+import ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet; +import ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet;
@@ -267,6 +251,7 @@ index 0000000000000000000000000000000000000000..a5d13c6b0d8765e4a65b43f5835fd907
+import net.minecraft.core.Direction; +import net.minecraft.core.Direction;
+import net.minecraft.core.Holder; +import net.minecraft.core.Holder;
+import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleOptions;
+import net.minecraft.server.level.ServerLevel;
+import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvent;
+import net.minecraft.util.Mth; +import net.minecraft.util.Mth;
+import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.damagesource.DamageSource;
@@ -276,10 +261,12 @@ index 0000000000000000000000000000000000000000..a5d13c6b0d8765e4a65b43f5835fd907
+import net.minecraft.world.level.Level; +import net.minecraft.world.level.Level;
+import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.AABB;
+import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.Vec3;
+import org.bukkit.craftbukkit.util.CraftVector;
+import org.bukkit.util.Vector; +import org.bukkit.util.Vector;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
+import java.util.List; +import java.util.List;
+import java.util.function.Consumer;
+ +
+public final class TntExplosion extends SpecialisedExplosion<PrimedTnt> { +public final class TntExplosion extends SpecialisedExplosion<PrimedTnt> {
+ private static final int ALL_DIRECTIONS = 0b111; + private static final int ALL_DIRECTIONS = 0b111;
@@ -291,10 +278,10 @@ index 0000000000000000000000000000000000000000..a5d13c6b0d8765e4a65b43f5835fd907
+ private int wrapped = 0; + private int wrapped = 0;
+ private boolean moved = false; + private boolean moved = false;
+ +
+ public TntExplosion(Level world, PrimedTnt tnt, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, BlockInteraction destructionType, ParticleOptions particle, ParticleOptions emitterParticle, Holder<SoundEvent> soundEvent) { + public TntExplosion(ServerLevel level, PrimedTnt tnt, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, Vec3 center, float power, boolean createFire, BlockInteraction destructionType, Consumer<SpecialisedExplosion<PrimedTnt>> applyEffects) {
+ super(world, tnt, damageSource, behavior, x, y, z, power, createFire, destructionType, particle, emitterParticle, soundEvent); + super(level, tnt, damageSource, behavior, center, power, createFire, destructionType, applyEffects);
+ this.originalPosition = this.position; + this.originalPosition = center;
+ this.bounds = new AABB(x, y, z, x, y, z); + this.bounds = new AABB(center, center);
+ } + }
+ +
+ @Override + @Override
@@ -309,29 +296,25 @@ index 0000000000000000000000000000000000000000..a5d13c6b0d8765e4a65b43f5835fd907
+ protected void startExplosion() { + protected void startExplosion() {
+ for (int i = this.getExplosionCount() - 1; i >= 0; --i) { + for (int i = this.getExplosionCount() - 1; i >= 0; --i) {
+ Vec3 previousMomentum = this.cause.entityState().momentum(); + Vec3 previousMomentum = this.cause.entityState().momentum();
+ boolean lastCycle = (i == 0); + boolean lastCycle = i == 0;
+ this.midExplosion(previousMomentum, lastCycle); // search for blocks and impact entities + List<BlockPos> toBlow = this.midExplosion(previousMomentum, lastCycle); // search for blocks and impact entities
+ +
+ if (!lastCycle) { + if (!lastCycle) {
+ EntityState entityState = this.nextSourceVelocity(); + EntityState entityState = this.nextSourceVelocity();
+ List<BlockPos> foundBlocks = new ObjectArrayList<>(this.getToBlow()); + List<BlockPos> foundBlocks = new ObjectArrayList<>(toBlow);
+ boolean destroyedBlocks = this.finalizeExplosionAndParticles(); + boolean destroyedBlocks = this.finalizeExplosionAndParticles(toBlow);
+ this.postExplosion(foundBlocks, destroyedBlocks); // update wrapped, clear recent block cache + this.postExplosion(foundBlocks, destroyedBlocks); // update wrapped, clear recent block cache
+ this.updateExplosionPosition(entityState, destroyedBlocks); + this.updateExplosionPosition(entityState, destroyedBlocks);
+ } + }
+ } + }
+ } + }
+ +
+ private void midExplosion(Vec3 previousMomentum, boolean lastCycle) { + private List<BlockPos> midExplosion(Vec3 previousMomentum, boolean lastCycle) {
+ final List<BlockPos> explodedPositions;
+ if (this.wrapped < FOUND_ALL_BLOCKS) { + if (this.wrapped < FOUND_ALL_BLOCKS) {
+ int blockX = Mth.floor(this.x); + explodedPositions = this.calculateExplodedPositions();
+ int blockY = Mth.floor(this.y); + } else {
+ int blockZ = Mth.floor(this.z); + explodedPositions = List.of();
+ long key = BlockPos.asLong(blockX, blockY, blockZ);
+ ExplosionBlockCache initialCache = this.getOrCacheExplosionBlock(blockX, blockY, blockZ, key, true);
+ if (initialCache.resistance <= (this.radius() * 1.3f) && this.interactsWithBlocks() && this.isRegionUnprotected()) { // Sakura - optimise protected explosions
+ this.searchForBlocks(this.recentBlockCache, initialCache);
+ }
+ } + }
+ +
+ if (this.wrapped < ALL_DIRECTIONS) { + if (this.wrapped < ALL_DIRECTIONS) {
@@ -345,39 +328,41 @@ index 0000000000000000000000000000000000000000..a5d13c6b0d8765e4a65b43f5835fd907
+ } + }
+ } + }
+ +
+ this.bounds = this.bounds.expand(this.position); + this.bounds = this.bounds.expand(this.center);
+ this.explosions.add(this.position); + this.explosions.add(this.center);
+ +
+ if (lastCycle || this.requiresImpactEntities()) { + if (lastCycle || this.requiresImpactEntities(explodedPositions, this.center)) {
+ this.locateAndImpactEntitiesInBounds(); + this.locateAndImpactEntitiesInBounds();
+ this.bounds = new AABB(this.position, this.position); + this.bounds = new AABB(this.center, this.center);
+ this.explosions.clear(); + this.explosions.clear();
+ } + }
+
+ return explodedPositions;
+ } + }
+ +
+ @Override + @Override
+ protected void postExplosion(List<BlockPos> foundBlocks, boolean destroyedBlocks) { + protected void postExplosion(List<BlockPos> foundBlocks, boolean destroyedBlocks) {
+ super.postExplosion(foundBlocks, destroyedBlocks); + super.postExplosion(foundBlocks, destroyedBlocks);
+ // Update wrapped, this is for tracking swinging and if blocks are found + // Update wrapped, this is for tracking swinging and if blocks are found
+ if (this.wrapped >= 7) { + if (this.wrapped >= ALL_DIRECTIONS) {
+ if (!destroyedBlocks && this.level.sakuraConfig().cannons.explosion.avoidRedundantBlockSearches) { + if (!destroyedBlocks && this.level().sakuraConfig().cannons.explosion.avoidRedundantBlockSearches) {
+ this.wrapped++; + this.wrapped++;
+ } else { + } else {
+ this.wrapped = 7; + this.wrapped = ALL_DIRECTIONS;
+ } + }
+ } + }
+ } + }
+ +
+ private Vector getCauseOrigin() { + private Vector getCauseOrigin() {
+ Vector origin = this.cause.getOriginVector(); + Vector origin = this.cause.getOriginVector();
+ return origin == null ? new Vector(this.x, this.y, this.z) : origin; + return origin == null ? CraftVector.toBukkit(this.center) : origin;
+ } + }
+ +
+ private EntityState nextSourceVelocity() { + private EntityState nextSourceVelocity() {
+ Vector origin = this.getCauseOrigin(); // valid position to use while creating a temporary entity + Vector origin = this.getCauseOrigin(); // valid position to use while creating a temporary entity
+ PrimedTnt tnt = new PrimedTnt(this.level, origin.getX(), origin.getY(), origin.getZ(), null); + PrimedTnt tnt = new PrimedTnt(this.level(), origin.getX(), origin.getY(), origin.getZ(), null);
+ this.cause.entityState().apply(tnt); + this.cause.entityState().apply(tnt);
+ this.impactCannonEntity(tnt, this.position, 1, this.radius() * 2.0f); + this.impactCannonEntity(tnt, this.center, 1, this.radius() * 2.0f);
+ return EntityState.of(tnt); + return EntityState.of(tnt);
+ } + }
+ +
@@ -386,7 +371,7 @@ index 0000000000000000000000000000000000000000..a5d13c6b0d8765e4a65b43f5835fd907
+ final boolean hasMoved; + final boolean hasMoved;
+ if (this.moved) { + if (this.moved) {
+ hasMoved = true; + hasMoved = true;
+ } else if (this.position.equals(this.cause.position())) { + } else if (this.center.equals(this.cause.position())) {
+ hasMoved = false; + hasMoved = false;
+ } else { + } else {
+ double newMomentum = entityState.momentum().lengthSqr(); + double newMomentum = entityState.momentum().lengthSqr();
@@ -402,13 +387,13 @@ index 0000000000000000000000000000000000000000..a5d13c6b0d8765e4a65b43f5835fd907
+ if (destroyedBlocks || hasMoved) { + if (destroyedBlocks || hasMoved) {
+ this.cause.setFuse(100); + this.cause.setFuse(100);
+ this.cause.tick(); + this.cause.tick();
+ this.moved |= !this.position.equals(this.originalPosition); + this.moved |= !this.center.equals(this.originalPosition);
+ this.recalculateExplosionPosition(); + this.recalculateExplosionPosition();
+ } + }
+ } + }
+ +
+ private void mergeEntitiesBeforeExplosion() { + private void mergeEntitiesBeforeExplosion() {
+ IteratorSafeOrderedReferenceSet<Entity> entities = this.level.entityTickList.entities; + IteratorSafeOrderedReferenceSet<Entity> entities = this.level().entityTickList.entities;
+ int index = entities.indexOf(this.cause); + int index = entities.indexOf(this.cause);
+ +
+ entities.createRawIterator(); + entities.createRawIterator();
@@ -417,7 +402,7 @@ index 0000000000000000000000000000000000000000..a5d13c6b0d8765e4a65b43f5835fd907
+ Entity foundEntity = entities.rawGet(index); + Entity foundEntity = entities.rawGet(index);
+ if (!(foundEntity instanceof MergeableEntity mergeEntity) || foundEntity.isRemoved() || !foundEntity.compareState(this.cause) || !mergeEntity.isSafeToMergeInto(this.cause, true)) + if (!(foundEntity instanceof MergeableEntity mergeEntity) || foundEntity.isRemoved() || !foundEntity.compareState(this.cause) || !mergeEntity.isSafeToMergeInto(this.cause, true))
+ break; + break;
+ this.level.mergeHandler.mergeEntity(mergeEntity, this.cause); + this.level().mergeHandler.mergeEntity(mergeEntity, this.cause);
+ } + }
+ entities.finishRawIterator(); + entities.finishRawIterator();
+ } + }
@@ -435,7 +420,7 @@ index 0000000000000000000000000000000000000000..a5d13c6b0d8765e4a65b43f5835fd907
+ if (moved) { + if (moved) {
+ this.impactEntitiesSwinging(entities, center, radius, maxDistanceSqr); + this.impactEntitiesSwinging(entities, center, radius, maxDistanceSqr);
+ } else { + } else {
+ this.impactEntitiesFromPosition(entities, this.explosions.get(0), this.explosions.size(), radius); + this.impactEntitiesFromPosition(entities, this.explosions.getFirst(), this.explosions.size(), radius);
+ } + }
+ }); + });
+ } + }
@@ -463,36 +448,55 @@ index 0000000000000000000000000000000000000000..a5d13c6b0d8765e4a65b43f5835fd907
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 0a29ad6409226ece40c03c6eba699592c7f0aa11..9e059ca44d19da96ff5fbe84a716e747036025d3 100644 index 1f278f6ef7e39df676334e7e5853dec4617f6baa..a9315006379f7ab5b40cb6aba7ed82727afe3a5a 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1798,6 +1798,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. @@ -1890,7 +1890,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
explosion.clearToBlow();
}
Explosion.BlockInteraction explosion_effect1 = explosion_effect;
Vec3 vec3d = new Vec3(d0, d1, d2);
- ServerExplosion serverexplosion = new ServerExplosion(this, entity, damagesource, explosiondamagecalculator, vec3d, f, flag, explosion_effect1);
+ // Sakura start - specialised explosions + // Sakura start - specialised explosions
+ this.notifyPlayersOfExplosion(x, y, z, power, explosion); + final ServerExplosion serverexplosion;
+ return explosion; + if (entity instanceof net.minecraft.world.entity.item.PrimedTnt tnt) {
+ } + serverexplosion = new me.samsuik.sakura.explosion.special.TntExplosion(this, tnt, damagesource, explosiondamagecalculator, vec3d, f, flag, explosion_effect1, self -> {
+ public final void notifyPlayersOfExplosion(double x, double y, double z, float power, Explosion explosion) { + this.notifyPlayersOfExplosion(self, self.center(), particleparam, particleparam1, holder);
+ });
+ } else {
+ serverexplosion = new ServerExplosion(this, entity, damagesource, explosiondamagecalculator, vec3d, f, flag, explosion_effect1);
+ }
+ // Sakura end - specialised explosions + // Sakura end - specialised explosions
if (configurator != null) configurator.accept(serverexplosion);// Paper - Allow explosions to damage source
serverexplosion.explode();
@@ -1899,6 +1908,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
return serverexplosion;
}
// CraftBukkit end
+ // Sakura start - specialised explosions
+ this.notifyPlayersOfExplosion(serverexplosion, vec3d, particleparam, particleparam1, holder);
+ return serverexplosion;
+ }
+
+ private void notifyPlayersOfExplosion(ServerExplosion serverexplosion, Vec3 vec3d, ParticleOptions particleparam, ParticleOptions particleparam1, Holder<SoundEvent> holder) {
+ // Sakura end - specialised explosions
ParticleOptions particleparam2 = serverexplosion.isSmall() ? particleparam : particleparam1;
Iterator iterator = this.players.iterator(); Iterator iterator = this.players.iterator();
while (iterator.hasNext()) { @@ -1912,7 +1928,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -1808,7 +1814,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
} }
} }
- return explosion; - return serverexplosion; // CraftBukkit
+ // Sakura - specialised explosions; return moved up into explode + // Sakura - specialised explosions; return moved up into explode
} }
@Override private Explosion.BlockInteraction getDestroyType(GameRules.Key<GameRules.BooleanValue> decayRule) {
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java 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 a8e540c8a27135336fb2d6e37aec13d598b2000e..e64c85bf8fbd3ad0d7e8a6e4a34aed8140f4f8bc 100644 index 6b739e820af6333c1ff3a4b87154d4c00c9a5559..0a9e62dd90c6aba4ff97391d69f9a92d9555cae6 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -73,20 +73,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak @@ -78,20 +78,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
@Override @Override
public final void respawnEntity(int count) { public final void respawnEntity(int count) {
@@ -514,65 +518,57 @@ index a8e540c8a27135336fb2d6e37aec13d598b2000e..e64c85bf8fbd3ad0d7e8a6e4a34aed81
} }
// Sakura end - merge cannon entities // Sakura end - merge cannon entities
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java
index 220d97947df493d1ab825e6637ca648e0b186d18..5cac17def6b49316ae8fb994d4f3d80154074fe0 100644 index 6001583d054b9690e34b6878b1298d93e6552a2a..11b12c1c4eff015bc40c7e7e965badb3f3fd272e 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java --- a/src/main/java/net/minecraft/world/level/ServerExplosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java
@@ -57,9 +57,11 @@ public class Explosion { @@ -52,9 +52,9 @@ public class ServerExplosion implements Explosion {
private final boolean fire;
private final Explosion.BlockInteraction blockInteraction; private final Explosion.BlockInteraction blockInteraction;
private final RandomSource random; private final ServerLevel level;
private final Level level; - private final Vec3 center;
- private final double x; + protected Vec3 center; // Sakura - specialised explosions; private final -> protected
- private final double y;
- private final double z;
+ // Sakura start - private -> protected
+ protected double x;
+ protected double y;
+ protected double z;
+ // Sakura end - private -> protected
@Nullable @Nullable
public final Entity source; - private final Entity source;
+ protected final Entity source; // Sakura - specialised explosions; private -> protected
private final float radius; private final float radius;
@@ -115,10 +117,10 @@ public class Explosion { private final DamageSource damageSource;
private final ExplosionDamageCalculator damageCalculator;
@@ -103,13 +103,13 @@ public class ServerExplosion implements Explosion {
// resistance = (res + 0.3F) * 0.3F; // resistance = (res + 0.3F) * 0.3F;
// so for resistance = 0, we need res = -0.3F // so for resistance = 0, we need res = -0.3F
private static final Float ZERO_RESISTANCE = Float.valueOf(-0.3f); private static final Float ZERO_RESISTANCE = Float.valueOf(-0.3f);
- private it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache> blockCache = null; - private it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache> blockCache = null;
+ protected it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache> blockCache = null; // Sakura - private -> protected + protected it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache> blockCache = null; // Sakura - specialised explosions; private -> protected
private long[] chunkPosCache = null; private long[] chunkPosCache = null;
private net.minecraft.world.level.chunk.LevelChunk[] chunkCache = null; private net.minecraft.world.level.chunk.LevelChunk[] chunkCache = null;
- private ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[] directMappedBlockCache;
+ protected ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[] directMappedBlockCache; // Sakura - specialised explosions; private -> protected
private BlockPos.MutableBlockPos mutablePos;
- private ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache getOrCacheExplosionBlock(final int x, final int y, final int z, - private ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache getOrCacheExplosionBlock(final int x, final int y, final int z,
+ protected final ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache getOrCacheExplosionBlock(final int x, final int y, final int z, // Sakura - private -> protected + protected final ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache getOrCacheExplosionBlock(final int x, final int y, final int z, // Sakura - specialised explosions; private -> protected
final long key, final boolean calculateResistance) { final long key, final boolean calculateResistance) {
ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache ret = this.blockCache.get(key); ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache ret = this.blockCache.get(key);
if (ret != null) { if (ret != null) {
@@ -216,7 +218,7 @@ public class Explosion { @@ -361,6 +361,38 @@ public class ServerExplosion implements Explosion {
(currZ & BLOCK_EXPLOSION_CACHE_MASK) << (BLOCK_EXPLOSION_CACHE_SHIFT + BLOCK_EXPLOSION_CACHE_SHIFT);
ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache cachedBlock = blockCache[cacheKey];
if (cachedBlock == null || cachedBlock.key != key) {
- blockCache[cacheKey] = cachedBlock = this.getOrCacheExplosionBlock(currX, currY, currZ, key, false);
+ blockCache[cacheKey] = cachedBlock = this.getOrCacheExplosionBlock(currX, currY, currZ, key, this.level.sakuraConfig().cannons.explosion.useBlockCacheAcrossExplosions); // Sakura - specialised explosions
}
final BlockState blockState = cachedBlock.blockState;
@@ -370,6 +372,28 @@ public class Explosion {
return true; return true;
} }
// Sakura end - optimise explosion protected regions // Sakura end - optimise explosion protected regions
+ // Sakura start - specialised explosions + // Sakura start - specialised explosions
+ protected final ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[] createBlockCache() { + protected final void createBlockCache() {
+ // Paper start - collision optimisations
+ this.blockCache = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>(); + this.blockCache = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>();
+
+ this.chunkPosCache = new long[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH]; + this.chunkPosCache = new long[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH];
+ java.util.Arrays.fill(this.chunkPosCache, ChunkPos.INVALID_CHUNK_POS); + java.util.Arrays.fill(this.chunkPosCache, ChunkPos.INVALID_CHUNK_POS);
+
+ this.chunkCache = new net.minecraft.world.level.chunk.LevelChunk[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH]; + this.chunkCache = new net.minecraft.world.level.chunk.LevelChunk[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH];
+ + this.directMappedBlockCache = new ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH];
+ return new ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH]; + this.mutablePos = new BlockPos.MutableBlockPos();
+ // Paper end - collision optimisations
+ } + }
+ +
+ protected final void markBlocksInCacheAsExplodable(List<BlockPos> blocks) { + protected final void markBlocksInCacheAsExplodable(List<BlockPos> explodedPositions) {
+ for (BlockPos blow : blocks) { + for (BlockPos blow : explodedPositions) {
+ ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache cache = this.blockCache.get(blow.asLong()); + ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache cache = this.blockCache.get(blow.asLong());
+ // May be null if the blockCache is cleared then retrieved from the recent block cache + // May be null if the blockCache is cleared then retrieved from the recent block cache
+ if (cache != null) { + if (cache != null) {
@@ -580,54 +576,84 @@ index 220d97947df493d1ab825e6637ca648e0b186d18..5cac17def6b49316ae8fb994d4f3d801
+ } + }
+ } + }
+ } + }
+
+ protected final void clearBlockCache() {
+ // Paper start - collision optimisations
+ this.blockCache = null;
+ this.chunkPosCache = null;
+ this.chunkCache = null;
+ this.directMappedBlockCache = null;
+ this.mutablePos = null;
+ // Paper end - collision optimisations
+ }
+ // Sakura end - specialised explosions + // Sakura end - specialised explosions
public static DamageSource getDefaultDamageSource(Level world, @Nullable Entity source) { public ServerExplosion(ServerLevel world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, Vec3 pos, float power, boolean createFire, Explosion.BlockInteraction destructionType) {
return world.damageSources().explosion(source, Explosion.getIndirectSourceEntityInternal(source)); this.level = world;
@@ -473,16 +497,7 @@ public class Explosion { @@ -432,7 +464,7 @@ public class ServerExplosion implements Explosion {
// CraftBukkit end return this.center;
this.level.gameEvent(this.source, (Holder) GameEvent.EXPLODE, new Vec3(this.x, this.y, this.z)); }
- private List<BlockPos> calculateExplodedPositions() {
+ protected final List<BlockPos> calculateExplodedPositions() { // Sakura - specialised explosions; private -> protected
// Paper start - collision optimisations
final ObjectArrayList<BlockPos> ret = new ObjectArrayList<>();
@@ -682,7 +714,7 @@ public class ServerExplosion implements Explosion {
}
- private void interactWithBlocks(List<BlockPos> positions) {
+ protected final void interactWithBlocks(List<BlockPos> positions) { // Sakura - specialised explosions; private -> protected
List<ServerExplosion.StackCollector> list1 = new ArrayList();
Util.shuffle(positions, this.level.random);
@@ -787,14 +819,7 @@ public class ServerExplosion implements Explosion {
return;
}
// CraftBukkit end
- // Paper start - collision optimisations - // Paper start - collision optimisations
- this.blockCache = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>(); - this.blockCache = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>();
-
- this.chunkPosCache = new long[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH]; - this.chunkPosCache = new long[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH];
- java.util.Arrays.fill(this.chunkPosCache, ChunkPos.INVALID_CHUNK_POS); - java.util.Arrays.fill(this.chunkPosCache, ChunkPos.INVALID_CHUNK_POS);
-
- this.chunkCache = new net.minecraft.world.level.chunk.LevelChunk[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH]; - this.chunkCache = new net.minecraft.world.level.chunk.LevelChunk[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH];
- - this.directMappedBlockCache = new ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH];
- final ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[] blockCache = new ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH]; - this.mutablePos = new BlockPos.MutableBlockPos();
- - // Paper end - collision optimisations
+ final ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[] blockCache = this.createBlockCache(); // Sakura - specialised explosions + this.createBlockCache(); // Sakura - specialised explosions
// use initial cache value that is most likely to be used: the source position this.level.gameEvent(this.source, (Holder) GameEvent.EXPLODE, this.center);
final ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache initialCache; List<BlockPos> list = this.calculateExplodedPositions();
{
@@ -964,7 +979,7 @@ public class Explosion { @@ -810,13 +835,7 @@ public class ServerExplosion implements Explosion {
private BlockInteraction() {} if (this.fire) {
this.createFire(list);
}
- // Paper start - collision optimisations
- this.blockCache = null;
- this.chunkPosCache = null;
- this.chunkCache = null;
- this.directMappedBlockCache = null;
- this.mutablePos = null;
- // Paper end - collision optimisations
+ this.clearBlockCache(); // Sakura - specialised explosions
} }
@@ -837,7 +856,7 @@ public class ServerExplosion implements Explosion {
}
- private boolean interactsWithBlocks() {
+ protected final boolean interactsWithBlocks() { // Sakura - specialised explosions; private -> protected
return this.blockInteraction != Explosion.BlockInteraction.KEEP;
}
@@ -904,7 +923,7 @@ public class ServerExplosion implements Explosion {
}
// Paper start - Optimize explosions // Paper start - Optimize explosions
- private float getBlockDensity(Vec3 vec3d, Entity entity, ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[] blockCache, BlockPos.MutableBlockPos blockPos) { // Paper - optimise collisions - private float getBlockDensity(Vec3 vec3d, Entity entity) {
+ protected final float getBlockDensity(Vec3 vec3d, Entity entity, ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[] blockCache, BlockPos.MutableBlockPos blockPos) { // Sakura - private -> protected // Paper - optimise collisions + protected final float getBlockDensity(Vec3 vec3d, Entity entity) { // Sakura - specialised explosions; private -> protected
// Sakura start - replace density cache // Sakura start - replace density cache
float blockDensity = this.level.densityCache.getDensity(vec3d, entity); float blockDensity = this.level.densityCache.getDensity(vec3d, entity);
if (blockDensity == me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) { if (blockDensity == me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index ed049df61d38ed06076273115b841e2852963844..c3260ad0ddb40fbde9c1aaf25c0a2be901357dcc 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -1537,7 +1537,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
}
Explosion.BlockInteraction explosion_effect1 = explosion_effect;
- Explosion explosion = new Explosion(this, entity, damageSource, behavior, x, y, z, power, createFire, explosion_effect1, particle, emitterParticle, soundEvent);
+ // Sakura start - specialised explosions
+ final Explosion explosion;
+ if (entity instanceof net.minecraft.world.entity.item.PrimedTnt tnt) {
+ explosion = new me.samsuik.sakura.explosion.special.TntExplosion(this, tnt, damageSource, behavior, x, y, z, power, createFire, explosion_effect1, particle, emitterParticle, soundEvent);
+ } else {
+ explosion = new Explosion(this, entity, damageSource, behavior, x, y, z, power, createFire, explosion_effect1, particle, emitterParticle, soundEvent);
+ }
+ // Sakura end - specialised explosions
if (configurator != null) configurator.accept(explosion); // Paper - Allow explosions to damage source
explosion.explode();

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Optimise cannon entity movement
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index a636c0331b6c963224727eaaed9c09d29ba9d2d7..ccbe81eb8df2406554c34e771b16855136db111c 100644 index c8b33f6d5b820da4b9e16b7d251ca4aad1875aa8..fcb0df76474b641ea86eeb87755faead66397d26 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1166,6 +1166,93 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1249,6 +1249,75 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return this.moveStartZ; return this.moveStartZ;
} }
// Paper end - detailed watchdog information // Paper end - detailed watchdog information
@@ -18,31 +18,28 @@ index a636c0331b6c963224727eaaed9c09d29ba9d2d7..ccbe81eb8df2406554c34e771b168551
+ if (this.noPhysics) { + if (this.noPhysics) {
+ this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); + this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z);
+ } else { + } else {
+ if (movementType == MoverType.PISTON) { // Paper + if (movementType == MoverType.PISTON) {
+ movement = this.limitPistonMovement(movement); + movement = this.limitPistonMovement(movement);
+ if (movement.equals(Vec3.ZERO)) { + if (movement.equals(Vec3.ZERO)) {
+ return; + return;
+ } + }
+ } + }
+ +
+ this.level().getProfiler().push("move"); + ProfilerFiller gameprofilerfiller = Profiler.get();
+ gameprofilerfiller.push("move");
+ if (this.stuckSpeedMultiplier.lengthSqr() > 1.0E-7D) { + if (this.stuckSpeedMultiplier.lengthSqr() > 1.0E-7D) {
+ movement = movement.multiply(this.stuckSpeedMultiplier); + movement = movement.multiply(this.stuckSpeedMultiplier);
+ this.stuckSpeedMultiplier = Vec3.ZERO; + this.stuckSpeedMultiplier = Vec3.ZERO;
+ this.setDeltaMovement(Vec3.ZERO); + this.setDeltaMovement(Vec3.ZERO);
+ } + }
+ +
+ // collideScan for optimised large movements
+ Vec3 vec3d1 = this.sakura_collide(movement); + Vec3 vec3d1 = this.sakura_collide(movement);
+ double d0 = vec3d1.lengthSqr(); + double d0 = vec3d1.lengthSqr();
+ +
+ if (d0 > 1.0E-7D) { + if (d0 > 1.0E-7D || movement.lengthSqr() - d0 < 1.0E-7D) {
+ // NOTE: Every minecraft update check if there are any new blocks that make sure of fallDistance.
+ // As of 1.21 the only block is powdered snow which returns a solid collision for falling blocks.
+ if (this.fallDistance != 0.0F && d0 >= 1.0D && !this.isFallingBlock) { + if (this.fallDistance != 0.0F && d0 >= 1.0D && !this.isFallingBlock) {
+ BlockHitResult movingobjectpositionblock = this.level().clip(new ClipContext(this.position(), this.position().add(vec3d1), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this)); + BlockHitResult clipResult = this.level().clip(new ClipContext(this.position(), this.position().add(vec3d1), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this));
+ + if (clipResult.getType() != HitResult.Type.MISS) {
+ if (movingobjectpositionblock.getType() != HitResult.Type.MISS) {
+ this.resetFallDistance(); + this.resetFallDistance();
+ } + }
+ } + }
@@ -50,59 +47,44 @@ index a636c0331b6c963224727eaaed9c09d29ba9d2d7..ccbe81eb8df2406554c34e771b168551
+ this.setPos(this.getX() + vec3d1.x, this.getY() + vec3d1.y, this.getZ() + vec3d1.z); + this.setPos(this.getX() + vec3d1.x, this.getY() + vec3d1.y, this.getZ() + vec3d1.z);
+ } + }
+ +
+ this.level().getProfiler().pop(); + gameprofilerfiller.pop();
+ this.level().getProfiler().push("rest"); + gameprofilerfiller.push("rest");
+ boolean flag = !Mth.equal(movement.x, vec3d1.x); + boolean movedX = !Mth.equal(movement.x, vec3d1.x);
+ boolean flag1 = !Mth.equal(movement.z, vec3d1.z); + boolean movedZ = !Mth.equal(movement.z, vec3d1.z);
+ +
+ this.horizontalCollision = flag || flag1; + this.horizontalCollision = movedX || movedZ;
+ this.verticalCollision = movement.y != vec3d1.y; + this.verticalCollision = movement.y != vec3d1.y;
+ this.verticalCollisionBelow = this.verticalCollision && movement.y < 0.0D; + this.verticalCollisionBelow = this.verticalCollision && movement.y < 0.0D;
+ if (this.horizontalCollision) {
+ this.minorHorizontalCollision = this.isHorizontalCollisionMinor(vec3d1);
+ } else {
+ this.minorHorizontalCollision = false;
+ }
+ +
+ this.setOnGroundWithMovement(this.verticalCollisionBelow, vec3d1); + this.setOnGroundWithMovement(this.verticalCollisionBelow, this.horizontalCollision, vec3d1);
+ BlockPos blockposition = this.getOnPosLegacy(); + BlockPos blockPosBelow = this.getOnPosLegacy();
+ BlockState iblockdata = this.level().getBlockState(blockposition); + BlockState blockstate = this.level().getBlockState(blockPosBelow);
+ +
+ this.checkFallDamage(vec3d1.y, this.onGround(), iblockdata, blockposition); + this.checkFallDamage(vec3d1.y, this.onGround(), blockstate, blockPosBelow);
+ if (this.isRemoved()) { + if (this.isRemoved()) {
+ this.level().getProfiler().pop(); + gameprofilerfiller.pop();
+ } else { + } else {
+ if (this.horizontalCollision) { + if (this.horizontalCollision) {
+ Vec3 vec3d2 = this.getDeltaMovement(); + Vec3 vec3d2 = this.getDeltaMovement();
+ + this.setDeltaMovement(movedX ? 0.0D : vec3d2.x, vec3d2.y, movedZ ? 0.0D : vec3d2.z);
+ this.setDeltaMovement(flag ? 0.0D : vec3d2.x, vec3d2.y, flag1 ? 0.0D : vec3d2.z);
+ } + }
+ +
+ Block block = iblockdata.getBlock(); + Block block = blockstate.getBlock();
+ + if (movement.y != vec3d1.y) { // remove y momentum
+ if (movement.y != vec3d1.y) { + block.updateEntityMovementAfterFallOn(this.level(), this);
+ block.updateEntityAfterFallOn(this.level(), this);
+ } + }
+ +
+ if (this.onGround()) {
+ // used for slowing down entities on top of slime
+ block.stepOn(this.level(), blockposition, iblockdata, this);
+ }
+
+ this.tryCheckInsideBlocks();
+
+ float f = this.getBlockSpeedFactor(); + float f = this.getBlockSpeedFactor();
+
+ this.setDeltaMovement(this.getDeltaMovement().multiply((double) f, 1.0D, (double) f)); + this.setDeltaMovement(this.getDeltaMovement().multiply((double) f, 1.0D, (double) f));
+ this.level().getProfiler().pop(); + gameprofilerfiller.pop();
+ } + }
+ } + }
+ } + }
+ // Sakura end - optimise cannon entity movement; stripped back movement method + // Sakura end - optimise cannon entity movement; stripped back movement method
public void move(MoverType movementType, Vec3 movement) { public void move(MoverType type, Vec3 movement) {
final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity
@@ -1510,6 +1597,104 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1610,6 +1679,107 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return offsetFactor; return offsetFactor;
} }
@@ -175,10 +157,13 @@ index a636c0331b6c963224727eaaed9c09d29ba9d2d7..ccbe81eb8df2406554c34e771b168551
+ +
+ private void collectCollisions(AABB collisionBox, List<VoxelShape> voxelList, List<AABB> bbList) { + private void collectCollisions(AABB collisionBox, List<VoxelShape> voxelList, List<AABB> bbList) {
+ // Copied from the collide method below + // Copied from the collide method below
+ ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getCollisions( + ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getCollisionsForBlocksOrWorldBorder(
+ this.level, this, collisionBox, voxelList, bbList, + this.level, this, collisionBox, voxelList, bbList,
+ ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER | this.getExtraCollisionFlags(), // Sakura - load chunks on movement + ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER | this.getExtraCollisionFlags(), null // Sakura - load chunks on movement
+ null, null + );
+
+ ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getEntityHardCollisions(
+ this.level, this, collisionBox, bbList, 0, null
+ ); + );
+ } + }
+ +
@@ -208,28 +193,28 @@ index a636c0331b6c963224727eaaed9c09d29ba9d2d7..ccbe81eb8df2406554c34e771b168551
// Paper start - optimise collisions // Paper start - optimise collisions
final boolean xZero = movement.x == 0.0; final boolean xZero = movement.x == 0.0;
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java 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 53488a1d0c56e7da4cf93c08cab01a033fb4f1f8..d1e06ef173468fa722d4b121e44ac0a9a314ee78 100644 index f0617e9d71fa47dfc0566f31d85b8a05ba3b16fc..32811e9d925911864e0c0fa5a2e25031098f423e 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -204,7 +204,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti @@ -213,7 +213,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
++this.time; ++this.time;
this.applyGravity(); this.applyGravity();
- this.move(MoverType.SELF, this.getDeltaMovement()); - this.move(MoverType.SELF, this.getDeltaMovement());
+ this.moveStripped(MoverType.SELF, this.getDeltaMovement()); // Sakura - optimise cannon entity movement + this.moveStripped(MoverType.SELF, this.getDeltaMovement()); // Sakura - optimise cannon entity movement
this.applyEffectsFromBlocks();
// Paper start - Configurable falling blocks height nerf // Paper start - Configurable falling blocks height nerf
if (this.level().paperConfig().fixes.fallingBlockHeightNerf.test(v -> this.getY() > v)) { if (this.level().paperConfig().fixes.fallingBlockHeightNerf.test(v -> this.getY() > v)) {
if (this.dropItem && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java 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 e64c85bf8fbd3ad0d7e8a6e4a34aed8140f4f8bc..1a2cdd2235dfa930e82151a370ddf2e60f2866fa 100644 index 0a9e62dd90c6aba4ff97391d69f9a92d9555cae6..7bb55565208b99db095c5842a7e21fd21700173e 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -124,7 +124,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak @@ -130,7 +130,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().spigotConfig.currentPrimedTnt > this.level().spigotConfig.maxTntTicksPerTick) { return; } // Spigot if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().spigotConfig.currentPrimedTnt > this.level().spigotConfig.maxTntTicksPerTick) { return; } // Spigot
this.handlePortal(); this.handlePortal();
this.applyGravity(); this.applyGravity();
- this.move(MoverType.SELF, this.getDeltaMovement()); - this.move(MoverType.SELF, this.getDeltaMovement());
+ this.moveStripped(MoverType.SELF, this.getDeltaMovement()); // Sakura - optimise cannon entity movement + this.moveStripped(MoverType.SELF, this.getDeltaMovement()); // Sakura - optimise cannon entity movement
this.applyEffectsFromBlocks();
// Paper start - Configurable TNT height nerf // Paper start - Configurable TNT 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(EntityRemoveEvent.Cause.OUT_OF_WORLD);

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Entity pushed by fluid API
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index ccbe81eb8df2406554c34e771b16855136db111c..33027663cd43f2a56b9cf09f280a277149aad427 100644 index fcb0df76474b641ea86eeb87755faead66397d26..1fa30edd2609523ede356d0ce30aa4f7b74968cc 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -603,6 +603,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -664,6 +664,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
} }
} }
// Sakura end - merge cannon entities // Sakura end - merge cannon entities
@@ -16,7 +16,7 @@ index ccbe81eb8df2406554c34e771b16855136db111c..33027663cd43f2a56b9cf09f280a2771
public Entity(EntityType<?> type, Level world) { public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet(); this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -4180,7 +4181,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -4481,7 +4482,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
} }
public boolean isPushedByFluid() { public boolean isPushedByFluid() {
@@ -26,10 +26,10 @@ index ccbe81eb8df2406554c34e771b16855136db111c..33027663cd43f2a56b9cf09f280a2771
public static double getViewScale() { 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 diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 89c8713d2c2206d1b0d8c0a392c9d13b3e736f0c..38ef55af47c7eb24ebc719c63298a9b071693f4e 100644 index 179886dcbda29c5cdb7dbd43e44951ae38d9df96..d0da1b34fe10be266f5b711e5755f07521e0bf08 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -203,6 +203,18 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @@ -204,6 +204,18 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return this.entity.isInWater(); return this.entity.isInWater();
} }

View File

@@ -5,7 +5,7 @@ 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 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 cc5ef63a99a18f093f600612bf972cf50722e3a5..c1a2345cbf3f2004fc679b1b4b1691cff288c6e4 100644 index 32811e9d925911864e0c0fa5a2e25031098f423e..e6e38c5f2922989c8616d0cf0bd7bd32403ea863 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -72,6 +72,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti @@ -72,6 +72,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
@@ -24,7 +24,7 @@ index cc5ef63a99a18f093f600612bf972cf50722e3a5..c1a2345cbf3f2004fc679b1b4b1691cf
} }
public FallingBlockEntity(Level world, double x, double y, double z, BlockState block) { public FallingBlockEntity(Level world, double x, double y, double z, BlockState block) {
@@ -190,6 +192,13 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti @@ -199,6 +201,13 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
return !this.isRemoved(); return !this.isRemoved();
} }
@@ -39,10 +39,10 @@ index cc5ef63a99a18f093f600612bf972cf50722e3a5..c1a2345cbf3f2004fc679b1b4b1691cf
protected double getDefaultGravity() { protected double getDefaultGravity() {
return 0.04D; return 0.04D;
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java 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 fdbc990af4190f93f207c3309cf9f89613092c0a..ee5d0dd90ebc2eb3280c9047450f8eac5dca167c 100644 index 7bb55565208b99db095c5842a7e21fd21700173e..93cf290b25d569820dd1bf9b4b5fb255abdbd8cd 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -96,6 +96,12 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak @@ -102,6 +102,12 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
this.yo = y; this.yo = y;
this.zo = z; this.zo = z;
this.owner = igniter; this.owner = igniter;
@@ -55,7 +55,7 @@ index fdbc990af4190f93f207c3309cf9f89613092c0a..ee5d0dd90ebc2eb3280c9047450f8eac
} }
@Override @Override
@@ -268,7 +274,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak @@ -286,7 +292,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
// Paper start - Option to prevent TNT from moving in water // Paper start - Option to prevent TNT from moving in water
@Override @Override
public boolean isPushedByFluid() { public boolean isPushedByFluid() {

View File

@@ -5,10 +5,10 @@ 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 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 b35f476e26a020cf75e53a5eb488717d996a6935..d555ad1dd2f648b84920eceec6cc99e8801334b3 100644 index e1c9a961064887070b29207efd7af47884f8dc29..f873061666cf7ba30b2b5dfe3b3a1ea85d2cdd4f 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
@@ -42,6 +42,11 @@ public class PistonMovingBlockEntity extends BlockEntity { @@ -43,6 +43,11 @@ public class PistonMovingBlockEntity extends BlockEntity {
private float progressO; private float progressO;
private long lastTicked; private long lastTicked;
private int deathTicks; private int deathTicks;
@@ -20,7 +20,7 @@ index b35f476e26a020cf75e53a5eb488717d996a6935..d555ad1dd2f648b84920eceec6cc99e8
public PistonMovingBlockEntity(BlockPos pos, BlockState state) { public PistonMovingBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntityType.PISTON, pos, state); super(BlockEntityType.PISTON, pos, state);
@@ -349,6 +354,18 @@ public class PistonMovingBlockEntity extends BlockEntity { @@ -358,6 +363,18 @@ public class PistonMovingBlockEntity extends BlockEntity {
} }
public VoxelShape getCollisionShape(BlockGetter world, BlockPos pos) { public VoxelShape getCollisionShape(BlockGetter world, BlockPos pos) {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Optimise TNT fluid state
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 33027663cd43f2a56b9cf09f280a277149aad427..c1c1737bc7f57b7112567fe22a31c964cf4d10f7 100644 index 1fa30edd2609523ede356d0ce30aa4f7b74968cc..4fe857bf47bc471eaf5c5bf40f59e117c4574798 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2162,7 +2162,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -2268,7 +2268,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return this.isInWater() || flag; return this.isInWater() || flag;
} }
@@ -16,12 +16,12 @@ index 33027663cd43f2a56b9cf09f280a277149aad427..c1c1737bc7f57b7112567fe22a31c964
+ protected void updateInWaterStateAndDoWaterCurrentPushing() { // Sakura + protected void updateInWaterStateAndDoWaterCurrentPushing() { // Sakura
Entity entity = this.getVehicle(); Entity entity = this.getVehicle();
if (entity instanceof Boat entityboat) { if (entity instanceof AbstractBoat abstractboat) {
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java 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 12983f598ffbd395b718878ac3865c0c5e5104fb..89d297bbec6034630fe0dbb84c079023611194a3 100644 index 93cf290b25d569820dd1bf9b4b5fb255abdbd8cd..f2206e57c04d29ed470ae2083b25ab502144ccb1 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -120,6 +120,21 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak @@ -126,6 +126,21 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
return !this.isRemoved(); return !this.isRemoved();
} }

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Add maxSearch to getEntities
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
index f3832bf2064117ef2fe804ae3fd679b1f2b0343b..9051dc762e48191fd56d26e0d0499ef12b10a240 100644 index 88b1a9b4b3da23b8e500ec343915e66e9b4f19b6..932d26a8c01414144aa56cdf9f6f63d07aff52d5 100644
--- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java --- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
@@ -336,10 +336,16 @@ public final class ChunkEntitySlices { @@ -315,10 +315,16 @@ public final class ChunkEntitySlices {
this.allEntities.getEntities(except, box, into, predicate); this.allEntities.getEntities(except, box, into, predicate);
} }
@@ -27,7 +27,7 @@ index f3832bf2064117ef2fe804ae3fd679b1f2b0343b..9051dc762e48191fd56d26e0d0499ef1
} }
public boolean getEntitiesWithoutDragonParts(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate, public boolean getEntitiesWithoutDragonParts(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate,
@@ -693,8 +699,16 @@ public final class ChunkEntitySlices { @@ -672,8 +678,16 @@ public final class ChunkEntitySlices {
} }
} }
@@ -44,7 +44,7 @@ index f3832bf2064117ef2fe804ae3fd679b1f2b0343b..9051dc762e48191fd56d26e0d0499ef1
if (this.count == 0) { if (this.count == 0) {
return false; return false;
} }
@@ -716,8 +730,14 @@ public final class ChunkEntitySlices { @@ -695,8 +709,14 @@ public final class ChunkEntitySlices {
final Entity[] storage = list.storage; final Entity[] storage = list.storage;
@@ -62,7 +62,7 @@ index f3832bf2064117ef2fe804ae3fd679b1f2b0343b..9051dc762e48191fd56d26e0d0499ef1
if (entity == null || entity == except || !entity.getBoundingBox().intersects(box)) { if (entity == null || entity == except || !entity.getBoundingBox().intersects(box)) {
continue; continue;
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java
index efc0c1acc8239dd7b00211a1d3bfd3fc3b2c810c..0ffbc8b459c3475ff0a9c307cb7bd144045f5f1c 100644 index 93335de8cf514dc8417e4b9b2d495663deda2904..774df86ba47ff6a7fa9fa38438824c64b569f665 100644
--- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java --- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java
@@ -801,8 +801,15 @@ public abstract class EntityLookup implements LevelEntityGetter<Entity> { @@ -801,8 +801,15 @@ public abstract class EntityLookup implements LevelEntityGetter<Entity> {
@@ -90,18 +90,11 @@ index efc0c1acc8239dd7b00211a1d3bfd3fc3b2c810c..0ffbc8b459c3475ff0a9c307cb7bd144
return; return;
} }
} }
@@ -1080,4 +1087,4 @@ public abstract class EntityLookup implements LevelEntityGetter<Entity> {
@Override
public void onRemove(final Entity.RemovalReason reason) {}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index c3260ad0ddb40fbde9c1aaf25c0a2be901357dcc..75d11642b7246bae4073feec09c0cf21c24622ca 100644 index b45ad0125cd5c116126e8ffb893585970ea3b960..2d5783a6ff7a9ce6dcb6f2895ff80928e62f0cd2 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -1685,10 +1685,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -1692,10 +1692,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
this.getEntities(filter, box, predicate, result, Integer.MAX_VALUE); this.getEntities(filter, box, predicate, result, Integer.MAX_VALUE);
} }
@@ -118,15 +111,15 @@ index c3260ad0ddb40fbde9c1aaf25c0a2be901357dcc..75d11642b7246bae4073feec09c0cf21
+ final AABB boundingBox, final Predicate<? super T> predicate, + final AABB boundingBox, final Predicate<? super T> predicate,
+ final List<? super T> into, final int maxCount, final int maxSearch) { + final List<? super T> into, final int maxCount, final int maxSearch) {
+ // Sakura end - add maxSearch to getEntities + // Sakura end - add maxSearch to getEntities
this.getProfiler().incrementCounter("getEntities"); Profiler.get().incrementCounter("getEntities");
if (entityTypeTest instanceof net.minecraft.world.entity.EntityType<T> byType) { if (entityTypeTest instanceof net.minecraft.world.entity.EntityType<T> byType) {
@@ -1703,7 +1711,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -1712,7 +1720,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
if (entityTypeTest == null) { if (entityTypeTest == null) {
if (maxCount != Integer.MAX_VALUE) { if (maxCount != Integer.MAX_VALUE) {
- ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities((Entity)null, boundingBox, (List)into, (Predicate)predicate, maxCount); - ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities((Entity)null, boundingBox, (List)into, (Predicate)predicate, maxCount);
+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities((Entity)null, boundingBox, (List)into, (Predicate)predicate, maxCount, maxSearch); // Sakura - add maxSearch to getEntities + ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities((Entity)null, boundingBox, (List)into, (Predicate)predicate, maxCount, maxSearch); // Sakura - add maxSearch to getEntities
ca.spottedleaf.moonrise.common.PlatformHooks.get().addToGetEntities((Level)(Object)this, entityTypeTest, boundingBox, predicate, into, maxCount);
return; return;
} else { } else {
((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities((Entity)null, boundingBox, (List)into, (Predicate)predicate);

View File

@@ -5,14 +5,14 @@ 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 diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index fe435d4a387bb28be6831cec0c8bb0a7c8b603a4..e39732b16d0b8d47759b8fc282e4a9a158991104 100644 index e3b81e5b2591fde8e15dfd0bee393000dd633096..a2724a075fc2f8c8127ed87cfa35d7ae72c347e8 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3629,7 +3629,12 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -3766,7 +3766,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
return; return;
} }
// Paper end - don't run getEntities if we're not going to use its result // Paper end - don't run getEntities if we're not going to use its result
- List<Entity> list = this.level().getEntities((Entity) this, this.getBoundingBox(), EntitySelector.pushable(this, this.level().paperConfig().collisions.fixClimbingBypassingCrammingRule)); // Paper - Climbing should not bypass cramming gamerule - List list = this.level().getEntities((Entity) this, this.getBoundingBox(), EntitySelector.pushable(this, this.level().paperConfig().collisions.fixClimbingBypassingCrammingRule)); // Paper - Climbing should not bypass cramming gamerule
+ // Sakura start - use maxEntityCollision limit for entity retrieval + // Sakura start - use maxEntityCollision limit for entity retrieval
+ int limit = Math.max(i, this.level().paperConfig().collisions.maxEntityCollisions); + int limit = Math.max(i, this.level().paperConfig().collisions.maxEntityCollisions);
+ int search = limit * limit; + int search = limit * limit;

View File

@@ -5,15 +5,15 @@ 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 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 c1a2345cbf3f2004fc679b1b4b1691cff288c6e4..e7c6074a83be4d93367c7465b74d79b4c00d1afd 100644 index e6e38c5f2922989c8616d0cf0bd7bd32403ea863..2f719d88d292fdf8e9fe51e3445b49e2ecc71e29 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/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 implements me.samsuik.sakura.enti @@ -255,7 +255,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
}
} }
}
- if (!this.onGround() && !flag1) { - if (!this.onGround() && !flag1) {
+ if (!this.onGround() && !flag1 || level().sakuraConfig().cannons.sand.despawnInsideMovingPistons && autoExpire && this.time > 600) { // Sakura - allow falling blocks to despawn inside moving pistons + if (!this.onGround() && !flag1 || this.level().sakuraConfig().cannons.sand.despawnInsideMovingPistons && autoExpire && this.time > 600) { // Sakura - allow falling blocks to despawn inside moving pistons
if (!this.level().isClientSide && ((this.time > 100 && autoExpire) && (blockposition.getY() <= this.level().getMinBuildHeight() || blockposition.getY() > this.level().getMaxBuildHeight()) || (this.time > 600 && autoExpire))) { // Paper - Expand FallingBlock API if ((this.time > 100 && autoExpire) && (blockposition.getY() <= this.level().getMinY() || blockposition.getY() > this.level().getMaxY()) || (this.time > 600 && autoExpire)) { // Paper - Expand FallingBlock API
if (this.dropItem && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { if (this.dropItem && worldserver.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
this.spawnAtLocation((ItemLike) block); this.spawnAtLocation(worldserver, (ItemLike) block);

View File

@@ -5,10 +5,10 @@ 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 diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index a744a01f3ef98e06af3696a58f5b1ae072dc8953..b188cc18d8bb6c37c1993bdaf39f521048d44956 100644 index a2724a075fc2f8c8127ed87cfa35d7ae72c347e8..9c21000c7e5202504ca08e5d87bb32bc674aa76c 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -1570,7 +1570,7 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -1604,7 +1604,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
} }
// Paper end - Check distance in entity interactions // Paper end - Check distance in entity interactions
@@ -17,7 +17,7 @@ index a744a01f3ef98e06af3696a58f5b1ae072dc8953..b188cc18d8bb6c37c1993bdaf39f5210
if (!flag) { if (!flag) {
this.indicateDamage(d0, d1); this.indicateDamage(d0, d1);
} }
@@ -1636,7 +1636,7 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -1674,7 +1674,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
} }
protected void blockedByShield(LivingEntity target) { protected void blockedByShield(LivingEntity target) {
@@ -26,7 +26,7 @@ index a744a01f3ef98e06af3696a58f5b1ae072dc8953..b188cc18d8bb6c37c1993bdaf39f5210
} }
private boolean checkTotemDeathProtection(DamageSource source) { private boolean checkTotemDeathProtection(DamageSource source) {
@@ -1955,7 +1955,7 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -2018,7 +2018,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
} }
public void knockback(double d0, double d1, double d2, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause cause) { // Paper - knockback events public void knockback(double d0, double d1, double d2, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause cause) { // Paper - knockback events
@@ -35,7 +35,7 @@ index a744a01f3ef98e06af3696a58f5b1ae072dc8953..b188cc18d8bb6c37c1993bdaf39f5210
if (true || d0 > 0.0D) { // CraftBukkit - Call event even when force is 0 if (true || d0 > 0.0D) { // CraftBukkit - Call event even when force is 0
//this.hasImpulse = true; // CraftBukkit - Move down //this.hasImpulse = true; // CraftBukkit - Move down
@@ -1966,9 +1966,21 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -2029,9 +2029,21 @@ public abstract class LivingEntity extends Entity implements Attackable {
} }
Vec3 vec3d1 = (new Vec3(d1, 0.0D, d2)).normalize().scale(d0); Vec3 vec3d1 = (new Vec3(d1, 0.0D, d2)).normalize().scale(d0);
@@ -59,7 +59,7 @@ index a744a01f3ef98e06af3696a58f5b1ae072dc8953..b188cc18d8bb6c37c1993bdaf39f5210
io.papermc.paper.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) this.getBukkitEntity(), attacker, attacker, cause, d0, diff); io.papermc.paper.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) this.getBukkitEntity(), attacker, attacker, cause, d0, diff);
// Paper end - knockback events // Paper end - knockback events
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java 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 8b2b495f34b1ae96901ed8f2ca2d8d753b4eb2c8..4c5779112c5e7b880627ecc446a295eeeadb396e 100644 index c3e90356ab409f408b767618db718e3926edf8d1..e50b64ba18fe8a4536b6f8aadca93064cd9f47f7 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java --- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -197,6 +197,7 @@ public abstract class Player extends LivingEntity { @@ -197,6 +197,7 @@ public abstract class Player extends LivingEntity {
@@ -70,7 +70,7 @@ index 8b2b495f34b1ae96901ed8f2ca2d8d753b4eb2c8..4c5779112c5e7b880627ecc446a295ee
// CraftBukkit start // CraftBukkit start
public boolean fauxSleeping; public boolean fauxSleeping;
@@ -1304,7 +1305,7 @@ public abstract class Player extends LivingEntity { @@ -1261,7 +1262,7 @@ public abstract class Player extends LivingEntity {
boolean flag = f2 > 0.9F; boolean flag = f2 > 0.9F;
boolean flag1; boolean flag1;
@@ -79,7 +79,7 @@ index 8b2b495f34b1ae96901ed8f2ca2d8d753b4eb2c8..4c5779112c5e7b880627ecc446a295ee
sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility
flag1 = true; flag1 = true;
} else { } else {
@@ -1347,7 +1348,21 @@ public abstract class Player extends LivingEntity { @@ -1304,7 +1305,21 @@ public abstract class Player extends LivingEntity {
float f5 = this.getKnockback(target, damagesource) + (flag1 ? 1.0F : 0.0F); float f5 = this.getKnockback(target, damagesource) + (flag1 ? 1.0F : 0.0F);
if (f5 > 0.0F) { if (f5 > 0.0F) {
@@ -102,7 +102,7 @@ index 8b2b495f34b1ae96901ed8f2ca2d8d753b4eb2c8..4c5779112c5e7b880627ecc446a295ee
LivingEntity entityliving1 = (LivingEntity) target; LivingEntity entityliving1 = (LivingEntity) target;
entityliving1.knockback((double) (f5 * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // Paper - knockback events entityliving1.knockback((double) (f5 * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // Paper - knockback events
@@ -1380,7 +1395,7 @@ public abstract class Player extends LivingEntity { @@ -1337,7 +1352,7 @@ public abstract class Player extends LivingEntity {
continue; continue;
} }
// CraftBukkit end // CraftBukkit end
@@ -112,10 +112,10 @@ index 8b2b495f34b1ae96901ed8f2ca2d8d753b4eb2c8..4c5779112c5e7b880627ecc446a295ee
Level world = this.level(); Level world = this.level();
diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
index 1223c5d23d0ea6aed068bdf0f5725e2ad49fc82c..43a3ac5858ffb2007e6f63ec0f3bc5a9971dce14 100644 index 4daa69c6be6d48563e30343a7e40e4da9ec7e5ad..c563f71fb79990771d032b8044b8f676d8d21058 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java --- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java +++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
@@ -299,6 +299,12 @@ public class FishingHook extends Projectile { @@ -304,6 +304,12 @@ public class FishingHook extends Projectile {
this.setHookedEntity(entityHitResult.getEntity()); this.setHookedEntity(entityHitResult.getEntity());
} }

View File

@@ -53,73 +53,72 @@ index 0000000000000000000000000000000000000000..e52cae27c2bbf4fa02d49d1c69d8e124
+ } + }
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/world/item/BlockItem.java b/src/main/java/net/minecraft/world/item/BlockItem.java
index 8041737aa751bec1c51ee3d9dacd6dfb2b845265..7073914cfd5759bea92ce098ad36a86afee5dd37 100644 index c816c935ecc74a811ffdffbe6ded73c06e92324a..4da4efe7114d4fcea5e79bcab292dc4b3c782de9 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/world/item/BlockItem.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/world/item/BlockItem.java
@@ -1824,6 +1824,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -47,8 +47,32 @@ public class BlockItem extends Item {
worldserver.localConfig().expire(currentTick); // Sakura - add local config this.block = block;
worldserver.mergeHandler.expire(currentTick); // Sakura - merge cannon entities
worldserver.densityCache.invalidate(); // Sakura - explosion density cache
+ worldserver.redstoneTracker.expire(currentTick); // Sakura
}
this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
diff --git a/src/main/java/net/minecraft/world/item/ItemNameBlockItem.java b/src/main/java/net/minecraft/world/item/ItemNameBlockItem.java
index a8008c7550488be34b51f4280f5569170b1ebd1d..ccc0e211648a77bb396b8b0e9d3b3984ba9b4f42 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 {
super(block, settings);
} }
+ // Sakura start - explosion durable blocks + // Sakura start - explosion durable blocks
+ @Override + private void sendBlockDurabilityToPlayer(UseOnContext context) {
+ public net.minecraft.world.InteractionResult useOn(net.minecraft.world.item.context.UseOnContext context) { + Player player = context.getPlayer();
+ Block itemBlock = this.getBlock(); + BlockState state = context.getLevel().getBlockState(context.getClickedPos());
+ if (context.getPlayer() != null && itemBlock.equals(net.minecraft.world.level.block.Blocks.POTATOES)) { + Block block = state.getBlock();
+ net.minecraft.world.entity.player.Player player = context.getPlayer(); + me.samsuik.sakura.explosion.durable.DurableMaterial material = context.getLevel().localConfig().config(context.getClickedPos()).durableMaterials.get(block);
+ net.minecraft.world.level.block.state.BlockState state = context.getLevel().getBlockState(context.getClickedPos());
+ Block block = state.getBlock();
+ me.samsuik.sakura.explosion.durable.DurableMaterial material = context.getLevel().localConfig().config(context.getClickedPos()).durableMaterials.get(block);
+ +
+ if (material != null) { + if (material != null) {
+ int durability = context.getLevel().durabilityManager.durability(context.getClickedPos(), material); + int remaining = context.getLevel().durabilityManager.durability(context.getClickedPos(), material);
+ this.sendPotatoMessage(player, durability, material.durability()); + int durability = material.durability();
+ } +
+ player.getBukkitEntity().sendRichMessage(
+ me.samsuik.sakura.configuration.GlobalConfiguration.get().messages.durableBlockInteraction,
+ 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))
+ );
+ } + }
+ return super.useOn(context);
+ } + }
+
+ private void sendPotatoMessage(net.minecraft.world.entity.player.Player player, int remaining, int durability) {
+ player.getBukkitEntity().sendRichMessage(
+ me.samsuik.sakura.configuration.GlobalConfiguration.get().messages.durableBlockInteraction,
+ 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 - explosion durable blocks
+ +
@Override @Override
public String getDescriptionId() { public InteractionResult useOn(UseOnContext context) {
return this.getOrCreateDescriptionId(); + if (this.getBlock() == net.minecraft.world.level.block.Blocks.POTATOES && context.getPlayer() != null) {
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java + this.sendBlockDurabilityToPlayer(context);
index 5cac17def6b49316ae8fb994d4f3d80154074fe0..407154670acbec704ef6804a33c320ab9246c16d 100644 + }
--- a/src/main/java/net/minecraft/world/level/Explosion.java + // Sakura end - explosion durable blocks
+++ b/src/main/java/net/minecraft/world/level/Explosion.java +
@@ -145,7 +145,7 @@ public class Explosion { InteractionResult enuminteractionresult = this.place(new BlockPlaceContext(context));
BlockState blockState = ((ca.spottedleaf.moonrise.patches.chunk_getblock.GetBlockChunk)chunk).moonrise$getBlock(x, y, z);
return !enuminteractionresult.consumesAction() && context.getItemInHand().has(DataComponents.CONSUMABLE) ? super.use(context.getLevel(), context.getPlayer(), context.getHand()) : enuminteractionresult;
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 2d5783a6ff7a9ce6dcb6f2895ff80928e62f0cd2..0ae2d83055252146e346b06cc8360eef56d39f5c 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -843,6 +843,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
// Paper end - optimise random ticking
public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities
public final me.samsuik.sakura.explosion.density.BlockDensityCache densityCache = new me.samsuik.sakura.explosion.density.BlockDensityCache(); // Sakura - explosion density cache
+ public final me.samsuik.sakura.explosion.durable.DurableBlockManager durabilityManager = new me.samsuik.sakura.explosion.durable.DurableBlockManager(); // Sakura - explosion durable blocks
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, 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, java.util.function.Supplier<me.samsuik.sakura.configuration.WorldConfiguration> sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura - sakura configuration files // Paper - create paper world config & Anti-Xray
// Paper start - getblock optimisations - cache world height/sections
diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java
index 11b12c1c4eff015bc40c7e7e965badb3f3fd272e..8268f8df624a73eaf0b8baad9aa16bab2ed0f0bc 100644
--- a/src/main/java/net/minecraft/world/level/ServerExplosion.java
+++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java
@@ -134,7 +134,7 @@ public class ServerExplosion implements Explosion {
BlockState blockState = ((ca.spottedleaf.moonrise.patches.getblock.GetBlockChunk)chunk).moonrise$getBlock(x, y, z);
FluidState fluidState = blockState.getFluidState(); FluidState fluidState = blockState.getFluidState();
- Optional<Float> resistance = !calculateResistance ? Optional.empty() : this.damageCalculator.getBlockExplosionResistance((Explosion)(Object)this, this.level, pos, blockState, fluidState); - Optional<Float> resistance = !calculateResistance ? Optional.empty() : this.damageCalculator.getBlockExplosionResistance((Explosion)(Object)this, this.level, pos, blockState, fluidState);
+ Optional<Float> resistance = !calculateResistance ? Optional.empty() : this.calculateBlockResistance(blockState, fluidState, pos); // Sakura - explosion durable blocks + Optional<Float> resistance = !calculateResistance ? Optional.empty() : this.calculateBlockResistance(blockState, fluidState, pos); // Sakura - explosion durable blocks
ret = new ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache( ret = new ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache(
key, pos, blockState, fluidState, key, pos, blockState, fluidState,
@@ -159,6 +159,21 @@ public class Explosion { @@ -393,6 +393,20 @@ public class ServerExplosion implements Explosion {
return ret; // Paper end - collision optimisations
} }
// Sakura end - specialised explosions
+ // Sakura start - explosion durable blocks + // Sakura start - explosion durable blocks
+ private Optional<Float> calculateBlockResistance(BlockState blockState, FluidState fluidState, BlockPos pos) { + private Optional<Float> calculateBlockResistance(BlockState blockState, FluidState fluidState, BlockPos pos) {
+ if (!blockState.isAir()) { + if (!blockState.isAir()) {
@@ -131,39 +130,26 @@ index 5cac17def6b49316ae8fb994d4f3d80154074fe0..407154670acbec704ef6804a33c320ab
+ } + }
+ } + }
+ +
+ return this.damageCalculator.getBlockExplosionResistance((Explosion)(Object)this, this.level, pos, blockState, fluidState); + return this.damageCalculator.getBlockExplosionResistance(this, this.level, pos, blockState, fluidState);
+ } + }
+ // Sakura end - explosion durable blocks + // Sakura end - explosion durable blocks
+
private boolean clipsAnything(final Vec3 from, final Vec3 to,
final ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.LazyEntityCollisionContext context,
final ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[] blockCache,
@@ -832,6 +847,16 @@ public class Explosion {
// CraftBukkit start - TNTPrimeEvent
BlockState iblockdata = this.level.getBlockState(blockposition);
Block block = iblockdata.getBlock();
+ // Sakura start - explosion durable blocks
+ 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);
+
+ if (material != null && material.durability() >= 0 && !this.level.durabilityManager.damage(blockposition, material)) {
+ objectlistiterator.remove();
+ continue;
+ }
+ }
+ // Sakura end - explosion durable blocks
if (block instanceof net.minecraft.world.level.block.TntBlock) {
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 75d11642b7246bae4073feec09c0cf21c24622ca..2cf25b6e51f1c430f80f1defe365b0373227bed2 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -697,6 +697,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
// Paper end - optimise random ticking
public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities
public final me.samsuik.sakura.explosion.density.BlockDensityCache densityCache = new me.samsuik.sakura.explosion.density.BlockDensityCache(); // Sakura - explosion density cache
+ public final me.samsuik.sakura.explosion.durable.DurableBlockManager durabilityManager = new me.samsuik.sakura.explosion.durable.DurableBlockManager(); // Sakura - explosion durable blocks
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 - sakura configuration files// Paper - create paper world config & Anti-Xray public ServerExplosion(ServerLevel world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, Vec3 pos, float power, boolean createFire, Explosion.BlockInteraction destructionType) {
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot this.level = world;
@@ -780,6 +794,16 @@ public class ServerExplosion implements Explosion {
}
}
// CraftBukkit end
+ // Sakura start - explosion durable blocks
+ 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);
+
+ if (material != null && material.durability() >= 0 && !this.level.durabilityManager.damage(blockposition, material)) {
+ iterator.remove();
+ continue;
+ }
+ }
+ // Sakura end - explosion durable blocks
this.level.getBlockState(blockposition).onExplosionHit(this.level, blockposition, this, (itemstack, blockposition1) -> {
ServerExplosion.addOrAppendStack(list1, itemstack, blockposition1);

View File

@@ -4,11 +4,11 @@ Date: Thu, 16 Nov 2023 00:59:04 +0000
Subject: [PATCH] Destroy Waterlogged Blocks 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 diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java
index 407154670acbec704ef6804a33c320ab9246c16d..b32f377079a7c97840079b0a6b541be936c822dd 100644 index 8268f8df624a73eaf0b8baad9aa16bab2ed0f0bc..cc97e3a88ea99362ec043edf13c1f54c2c75daaa 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java --- a/src/main/java/net/minecraft/world/level/ServerExplosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java
@@ -168,6 +168,11 @@ public class Explosion { @@ -402,6 +402,11 @@ public class ServerExplosion implements Explosion {
if (material != null && material.resistance() >= 0.0f && (this.level.sakuraConfig().cannons.explosion.allowNonTntBreakingDurableBlocks || this.source instanceof net.minecraft.world.entity.item.PrimedTnt)) { if (material != null && material.resistance() >= 0.0f && (this.level.sakuraConfig().cannons.explosion.allowNonTntBreakingDurableBlocks || this.source instanceof net.minecraft.world.entity.item.PrimedTnt)) {
return Optional.of(material.resistance()); return Optional.of(material.resistance());
} }
@@ -19,4 +19,4 @@ index 407154670acbec704ef6804a33c320ab9246c16d..b32f377079a7c97840079b0a6b541be9
+ // Sakura end - destroy water logged blocks + // Sakura end - destroy water logged blocks
} }
return this.damageCalculator.getBlockExplosionResistance((Explosion)(Object)this, this.level, pos, blockState, fluidState); return this.damageCalculator.getBlockExplosionResistance(this, this.level, pos, blockState, fluidState);

View File

@@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
Date: Thu, 16 Nov 2023 20:53:51 +0000
Subject: [PATCH] Falling Block Stacking Restrictions
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 2f719d88d292fdf8e9fe51e3445b49e2ecc71e29..890f1d6f8ad740afb0b30208f7cd42594e4c9d20 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -273,7 +273,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
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) {
this.blockState = (BlockState) this.blockState.setValue(BlockStateProperties.WATERLOGGED, true);
}

View File

@@ -5,24 +5,18 @@ 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 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 4423973d4d9a2c3879d98d1d4c8b8c117c677ac5..634a2e000ad788525fbb9f76be9cab8b0397dccc 100644 index 0f086af57a5ff08c264dcbf89a8c3931ec73a609..d9a6324eeb0cfaef3d0bbff884ddfadc6e4132f7 100644
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
@@ -590,6 +590,17 @@ public class ItemEntity extends Entity implements TraceableEntity { @@ -410,6 +410,11 @@ public class ItemEntity extends Entity implements TraceableEntity {
} @Override
public boolean ignoreExplosion(Explosion explosion) {
+ // Sakura start + // Sakura start - add list of items that ignore explosions
+ @Override
+ public boolean ignoreExplosion(net.minecraft.world.level.Explosion explosion) {
+ if (this.level().sakuraConfig().entity.items.explosionResistantItems.contains(this.getItem().getItem())) { + if (this.level().sakuraConfig().entity.items.explosionResistantItems.contains(this.getItem().getItem())) {
+ return true; + return true;
+ } else {
+ return super.ignoreExplosion(explosion);
+ } + }
+ } + // Sakura end - add list of items that ignore explosions
+ // Sakura end return explosion.shouldAffectBlocklikeEntities() ? super.ignoreExplosion(explosion) : true;
+
public void setTarget(@Nullable UUID owner) {
this.target = owner;
} }

View File

@@ -1,19 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
Date: Thu, 16 Nov 2023 20:53:51 +0000
Subject: [PATCH] Falling Block Stacking Restrictions
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 e7c6074a83be4d93367c7465b74d79b4c00d1afd..b5ce3bbce3cc71bab5ec5e9c1c42e7b7a2cdefa3 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -258,7 +258,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
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) {
this.blockState = (BlockState) this.blockState.setValue(BlockStateProperties.WATERLOGGED, true);
}

View File

@@ -5,10 +5,10 @@ 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 diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index 763abeea3f14f15c27d600e0bdae44b387687bb4..498367016c764635215b49e177759c30622de15e 100644 index dbd321f3dc3cc80737830db63aed47a6935e8e89..0f7fbb0e3ccc47711bc5dddd046f96f2bfda7ebd 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java --- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -912,7 +912,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab @@ -910,7 +910,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
protected final void serverAiStep() { protected final void serverAiStep() {
++this.noActionTime; ++this.noActionTime;
// Paper start - Allow nerfed mobs to jump and float // Paper start - Allow nerfed mobs to jump and float

View File

@@ -0,0 +1,35 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
Date: Mon, 20 Nov 2023 19:32:31 +0000
Subject: [PATCH] Consistent Explosion Radius
diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java
index cc97e3a88ea99362ec043edf13c1f54c2c75daaa..1a912813ab7fa112379876ea1d4c903afe45c069 100644
--- a/src/main/java/net/minecraft/world/level/ServerExplosion.java
+++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java
@@ -412,6 +412,7 @@ public class ServerExplosion implements Explosion {
return this.damageCalculator.getBlockExplosionResistance(this, this.level, pos, blockState, fluidState);
}
// Sakura end - explosion durable blocks
+ private final boolean consistentRadius; // Sakura - consistent explosion radius
public ServerExplosion(ServerLevel world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, Vec3 pos, float power, boolean createFire, Explosion.BlockInteraction destructionType) {
this.level = world;
@@ -423,6 +424,7 @@ public class ServerExplosion implements Explosion {
this.damageSource = damageSource == null ? world.damageSources().explosion(this) : damageSource;
this.damageCalculator = behavior == null ? this.makeDamageCalculator(entity) : behavior;
this.yield = this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F; // CraftBukkit
+ this.consistentRadius = world.localConfig().config(BlockPos.containing(this.center)).consistentRadius; // Sakura - consistent explosion radius
}
private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) {
@@ -533,7 +535,7 @@ public class ServerExplosion implements Explosion {
ray += 3;
- float power = this.radius * (0.7F + this.level.random.nextFloat() * 0.6F);
+ float power = this.radius * (0.7F + (this.consistentRadius ? 0.7F : this.level.random.nextFloat()) * 0.6F); // Sakura - consistent explosion radius
do {
final int blockX = Mth.floor(currX);

View File

@@ -1,35 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
Date: Mon, 20 Nov 2023 19:32:31 +0000
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 b32f377079a7c97840079b0a6b541be936c822dd..fa142719b1c4f6434466141128c475ef945edbb7 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -77,6 +77,7 @@ public class Explosion {
public float yield;
// CraftBukkit end
public boolean excludeSourceFromDamage = true; // Paper - Allow explosions to damage source
+ private final boolean consistentRadius; // Sakura - consistent explosion radius
// Paper start - optimise collisions
private static final double[] CACHED_RAYS;
@@ -451,6 +452,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
+ this.consistentRadius = world.localConfig().config(BlockPos.containing(x, y, z)).consistentRadius; // Sakura - consistent explosion radius
}
private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) {
@@ -559,7 +561,7 @@ public class Explosion {
final double incZ = CACHED_RAYS[ray + 2];
ray += 3;
- float power = this.radius * (0.7F + this.level.random.nextFloat() * 0.6F);
+ float power = this.radius * (0.7F + (this.consistentRadius ? 0.7F : this.level.random.nextFloat()) * 0.6F); // Sakura - consistent explosion radius
do {
final int blockX = Mth.floor(currX);
final int blockY = Mth.floor(currY);

View File

@@ -5,10 +5,10 @@ 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 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 64ebae26c3c58c94b9907a5819cdc09f4f748cf1..56ad11f51e3ec395a88fa6d961cf8e99bde6b69f 100644 index f2206e57c04d29ed470ae2083b25ab502144ccb1..3e4935f4a07fa14152d1f55f069c49fdd2f3bc02 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -142,7 +142,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak @@ -148,7 +148,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
@Override @Override
public void tick() { public void tick() {

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 diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 64b55ad9544867ad0423aec368ff878d3ab8168f..0fed8714e1d01c6f584d6de00fba3635740298f6 100644 index 9c21000c7e5202504ca08e5d87bb32bc674aa76c..d302b53d1d6052b4982fedb496b4d100f75bbe33 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3578,7 +3578,7 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -3696,7 +3696,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
// Paper end - Add EntityMoveEvent
world = this.level();
if (world instanceof ServerLevel worldserver) {
- if (this.isSensitiveToWater() && this.isInWaterRainOrBubble()) {
+ if (this.level().sakuraConfig().entity.waterSensitivity && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) { // Sakura - configure entity water sensitivity
this.hurtServer(worldserver, this.damageSources().drown(), 1.0F);
} }
} }
// Paper end - Add EntityMoveEvent
- if (!this.level().isClientSide && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) {
+ if (!this.level().isClientSide && this.level().sakuraConfig().entity.waterSensitivity && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) { // Sakura - configure entity water sensitivity
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/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
index ea6e252053b8910141aacd5bb82108d6abf3fb96..aa23d2665d5804e31b7c1b7021377010e74e4718 100644 index 149e461fcb23b2ed7ae8dcc09837de501ba9eafb..613d2d90571546a482ba493fae5cbc7c69dd8f08 100644
--- a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java --- a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
@@ -1463,6 +1463,14 @@ public final class CollisionUtil { @@ -1799,6 +1799,13 @@ public final class CollisionUtil {
} }
public static net.minecraft.world.phys.Vec3 performAABBCollisions(final net.minecraft.world.phys.Vec3 moveVector, net.minecraft.world.phys.AABB axisalignedbb, final java.util.List<net.minecraft.world.phys.AABB> potentialCollisions) { public static Vec3 performAABBCollisions(final Vec3 moveVector, AABB axisalignedbb, final List<AABB> potentialCollisions) {
+ // Sakura start - physics version api + // Sakura start - physics version api
+ return performAABBCollisions(moveVector, axisalignedbb, potentialCollisions, null); + return performAABBCollisions(moveVector, axisalignedbb, potentialCollisions, null);
+ } + }
+ public static net.minecraft.world.phys.Vec3 performAABBCollisions(final net.minecraft.world.phys.Vec3 moveVector, + public static Vec3 performAABBCollisions(final Vec3 moveVector, AABB axisalignedbb,
+ net.minecraft.world.phys.AABB axisalignedbb, + final List<AABB> potentialCollisions,
+ final java.util.List<net.minecraft.world.phys.AABB> potentialCollisions, + final me.samsuik.sakura.physics.PhysicsVersion physics) {
+ final me.samsuik.sakura.physics.PhysicsVersion physics) {
+ // Sakura end - physics version api + // Sakura end - physics version api
double x = moveVector.x; double x = moveVector.x;
double y = moveVector.y; double y = moveVector.y;
double z = moveVector.z; double z = moveVector.z;
@@ -1474,7 +1482,10 @@ public final class CollisionUtil { @@ -1810,7 +1817,10 @@ public final class CollisionUtil {
} }
} }
@@ -35,17 +34,18 @@ index ea6e252053b8910141aacd5bb82108d6abf3fb96..aa23d2665d5804e31b7c1b7021377010
if (xSmaller && z != 0.0) { if (xSmaller && z != 0.0) {
z = performAABBCollisionsZ(axisalignedbb, z, potentialCollisions); z = performAABBCollisionsZ(axisalignedbb, z, potentialCollisions);
@@ -1500,9 +1511,17 @@ public final class CollisionUtil { @@ -1836,9 +1846,18 @@ public final class CollisionUtil {
public static net.minecraft.world.phys.Vec3 performCollisions(final net.minecraft.world.phys.Vec3 moveVector, net.minecraft.world.phys.AABB axisalignedbb, public static Vec3 performCollisions(final Vec3 moveVector, AABB axisalignedbb,
final java.util.List<net.minecraft.world.phys.shapes.VoxelShape> voxels, final List<VoxelShape> voxels,
final java.util.List<net.minecraft.world.phys.AABB> aabbs) { final List<AABB> aabbs) {
+ // Sakura start - physics version api + // Sakura start - physics version api
+ return performCollisions(moveVector, axisalignedbb, voxels, aabbs, null); + return performCollisions(moveVector, axisalignedbb, voxels, aabbs, null);
+ } + }
+ public static net.minecraft.world.phys.Vec3 performCollisions(final net.minecraft.world.phys.Vec3 moveVector, net.minecraft.world.phys.AABB axisalignedbb, +
+ final java.util.List<net.minecraft.world.phys.shapes.VoxelShape> voxels, + public static Vec3 performCollisions(final Vec3 moveVector, AABB axisalignedbb,
+ final java.util.List<net.minecraft.world.phys.AABB> aabbs, + final List<VoxelShape> voxels,
+ final me.samsuik.sakura.physics.PhysicsVersion physics) { + final List<AABB> aabbs,
+ final me.samsuik.sakura.physics.PhysicsVersion physics) {
+ // Sakura end - physics version api + // Sakura end - physics version api
if (voxels.isEmpty()) { if (voxels.isEmpty()) {
// fast track only AABBs // fast track only AABBs
@@ -54,7 +54,7 @@ index ea6e252053b8910141aacd5bb82108d6abf3fb96..aa23d2665d5804e31b7c1b7021377010
} }
double x = moveVector.x; double x = moveVector.x;
@@ -1517,7 +1536,10 @@ public final class CollisionUtil { @@ -1853,7 +1872,10 @@ public final class CollisionUtil {
} }
} }
@@ -67,10 +67,10 @@ index ea6e252053b8910141aacd5bb82108d6abf3fb96..aa23d2665d5804e31b7c1b7021377010
if (xSmaller && z != 0.0) { if (xSmaller && z != 0.0) {
z = performAABBCollisionsZ(axisalignedbb, z, aabbs); z = performAABBCollisionsZ(axisalignedbb, z, aabbs);
diff --git a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java diff --git a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java
index 86a4b9502df49b1614fc76920b164e1148244643..8db362721860fe8d5eb497a766e6d1b7879cb455 100644 index 4cbef703a70208191d13075c2c54581eb8239f70..2ac8bd2cc879c493d9a008f7555c7277977129f5 100644
--- a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java --- a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java
+++ b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java +++ b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java
@@ -180,9 +180,15 @@ public abstract class SpecialisedExplosion<T extends Entity> extends Explosion { @@ -164,9 +164,15 @@ public abstract class SpecialisedExplosion<T extends Entity> extends ServerExplo
if (distanceFromBottom <= 1.0) { if (distanceFromBottom <= 1.0) {
double x = entity.getX() - pos.x; double x = entity.getX() - pos.x;
@@ -88,11 +88,11 @@ index 86a4b9502df49b1614fc76920b164e1148244643..8db362721860fe8d5eb497a766e6d1b7
if (distance != 0.0D) { if (distance != 0.0D) {
x /= distance; x /= distance;
diff --git a/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java b/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java diff --git a/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java b/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java
index a5d13c6b0d8765e4a65b43f5835fd907738e1da4..19f0d8cf94a60b66cead3c129ded69fc3a2da0ce 100644 index d5bd783cca91ab292cd9957fe25803773f75c4ee..f08500cb89099896de45270386bb9b85f1230157 100644
--- a/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java --- a/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java
+++ b/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java +++ b/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java
@@ -40,6 +40,13 @@ public final class TntExplosion extends SpecialisedExplosion<PrimedTnt> { @@ -43,6 +43,13 @@ public final class TntExplosion extends SpecialisedExplosion<PrimedTnt> {
this.bounds = new AABB(x, y, z, x, y, z); this.bounds = new AABB(center, center);
} }
+ // Sakura start - physics version api + // Sakura start - physics version api
@@ -106,7 +106,7 @@ index a5d13c6b0d8765e4a65b43f5835fd907738e1da4..19f0d8cf94a60b66cead3c129ded69fc
protected int getExplosionCount() { protected int getExplosionCount() {
if (this.cause.getMergeEntityData().getMergeLevel() == MergeLevel.NONE) { if (this.cause.getMergeEntityData().getMergeLevel() == MergeLevel.NONE) {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index c1c1737bc7f57b7112567fe22a31c964cf4d10f7..ba94f23803adc9b83e46a7ed936e178064a42e71 100644 index 4fe857bf47bc471eaf5c5bf40f59e117c4574798..671bd5aa322a1516776163827c0fc4c85c84615e 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -384,7 +384,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -384,7 +384,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -117,8 +117,8 @@ index c1c1737bc7f57b7112567fe22a31c964cf4d10f7..ba94f23803adc9b83e46a7ed936e1780
+ protected float eyeHeight; // Sakura - private -> protected + protected float eyeHeight; // Sakura - private -> protected
public boolean isInPowderSnow; public boolean isInPowderSnow;
public boolean wasInPowderSnow; public boolean wasInPowderSnow;
public boolean wasOnFire; public Optional<BlockPos> mainSupportingBlockPos;
@@ -604,6 +604,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -665,6 +665,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
} }
// Sakura end - merge cannon entities // Sakura end - merge cannon entities
public boolean pushedByFluid = true; // Sakura - entity pushed by fluid api public boolean pushedByFluid = true; // Sakura - entity pushed by fluid api
@@ -132,7 +132,7 @@ index c1c1737bc7f57b7112567fe22a31c964cf4d10f7..ba94f23803adc9b83e46a7ed936e1780
public Entity(EntityType<?> type, Level world) { public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet(); this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -1113,7 +1120,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1196,7 +1203,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
} }
protected void checkSupportingBlock(boolean onGround, @Nullable Vec3 movement) { protected void checkSupportingBlock(boolean onGround, @Nullable Vec3 movement) {
@@ -141,74 +141,39 @@ index c1c1737bc7f57b7112567fe22a31c964cf4d10f7..ba94f23803adc9b83e46a7ed936e1780
AABB axisalignedbb = this.getBoundingBox(); AABB axisalignedbb = this.getBoundingBox();
AABB axisalignedbb1 = new AABB(axisalignedbb.minX, axisalignedbb.minY - 1.0E-6D, axisalignedbb.minZ, axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ); 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); Optional<BlockPos> optional = this.level.findSupportingBlock(this, axisalignedbb1);
@@ -1173,7 +1180,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1256,7 +1263,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
if (this.noPhysics) { if (this.noPhysics) {
this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z);
} else { } else {
- if (movementType == MoverType.PISTON) { // Paper - if (movementType == MoverType.PISTON) {
+ if (movementType == MoverType.PISTON && this.physics.afterOrEqual(1_11_0)) { // Sakura - physics version api // Paper + if (movementType == MoverType.PISTON && this.physics.afterOrEqual(1_11_0)) { // Sakura - physics version api
movement = this.limitPistonMovement(movement); movement = this.limitPistonMovement(movement);
if (movement.equals(Vec3.ZERO)) { if (movement.equals(Vec3.ZERO)) {
return; return;
@@ -1191,10 +1198,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1274,8 +1281,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
Vec3 vec3d1 = this.sakura_collide(movement); Vec3 vec3d1 = this.sakura_collide(movement);
double d0 = vec3d1.lengthSqr(); double d0 = vec3d1.lengthSqr();
- if (d0 > 1.0E-7D) { - if (d0 > 1.0E-7D || movement.lengthSqr() - d0 < 1.0E-7D) {
- // NOTE: Every minecraft update check if there are any new blocks that make sure of fallDistance.
+ if (d0 > 1.0E-7D || this.physics.before(1_14_0)) { // Sakura - physics version api
+ // NOTE: Every minecraft update check if there are any new blocks that make use of fallDistance.
// As of 1.21 the only block is powdered snow which returns a solid collision for falling blocks.
- if (this.fallDistance != 0.0F && d0 >= 1.0D && !this.isFallingBlock) { - if (this.fallDistance != 0.0F && d0 >= 1.0D && !this.isFallingBlock) {
+ if (d0 > 1.0E-7D || this.physics.afterOrEqual(1_21_2) && movement.lengthSqr() - d0 < 1.0E-7D || this.physics.before(1_14_0)) { // Sakura - physics version api
+ if (this.fallDistance != 0.0F && d0 >= 1.0D && !this.isFallingBlock && this.physics.afterOrEqual(1_18_2)) { // Sakura - physics version api + if (this.fallDistance != 0.0F && d0 >= 1.0D && !this.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 clipResult = this.level().clip(new ClipContext(this.position(), this.position().add(vec3d1), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this));
if (clipResult.getType() != HitResult.Type.MISS) {
if (movingobjectpositionblock.getType() != HitResult.Type.MISS) { this.resetFallDistance();
@@ -1230,6 +1237,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1304,6 +1311,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
} else {
if (this.horizontalCollision) { if (this.horizontalCollision) {
Vec3 vec3d2 = this.getDeltaMovement(); Vec3 vec3d2 = this.getDeltaMovement();
+ // Sakura start - physics version api + // Sakura start - physics version api
+ if (flag && flag1 && this.physics.isWithin(1_14_0, 1_18_1)) { + if (movedX && movedZ && this.physics.isWithin(1_14_0, 1_18_1)) {
+ flag = false; + movedX = false;
+ } + }
+ // Sakura end - physics version api + // Sakura end - physics version api
this.setDeltaMovement(flag ? 0.0D : vec3d2.x, vec3d2.y, flag1 ? 0.0D : vec3d2.z); this.setDeltaMovement(movedX ? 0.0D : vec3d2.x, vec3d2.y, movedZ ? 0.0D : vec3d2.z);
} }
@@ -1271,7 +1283,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1709,7 +1721,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z);
} else {
this.wasOnFire = this.isOnFire();
- if (movementType == MoverType.PISTON) {
+ if (movementType == MoverType.PISTON && this.physics.afterOrEqual(1_11_0)) { // Sakura - physics version api
this.activatedTick = Math.max(this.activatedTick, MinecraftServer.currentTick + 20); // Paper
this.activatedImmunityTick = Math.max(this.activatedImmunityTick, MinecraftServer.currentTick + 20); // Paper
movement = this.limitPistonMovement(movement);
@@ -1298,8 +1310,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
Vec3 vec3d1 = this.collide(movement);
double d0 = vec3d1.lengthSqr();
- if (d0 > 1.0E-7D) {
- 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));
if (movingobjectpositionblock.getType() != HitResult.Type.MISS) {
@@ -1335,6 +1347,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
if (this.horizontalCollision) {
Vec3 vec3d2 = this.getDeltaMovement();
+ // Sakura start - physics version api
+ if (flag && flag1 && this.physics.isWithin(1_14_0, 1_18_1)) {
+ flag = false;
+ }
+ // Sakura end - physics version api
this.setDeltaMovement(flag ? 0.0D : vec3d2.x, vec3d2.y, flag1 ? 0.0D : vec3d2.z);
}
@@ -1627,7 +1644,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
bb = currBoundingBox.expandTowards(movement.x, movement.y, movement.z); bb = currBoundingBox.expandTowards(movement.x, movement.y, movement.z);
} }
this.collectCollisions(bb, voxelList, bbList); this.collectCollisions(bb, voxelList, bbList);
@@ -217,7 +182,7 @@ index c1c1737bc7f57b7112567fe22a31c964cf4d10f7..ba94f23803adc9b83e46a7ed936e1780
} }
private Vec3 collideAxisScan(Vec3 movement, AABB currBoundingBox, List<VoxelShape> voxelList, List<AABB> bbList) { private Vec3 collideAxisScan(Vec3 movement, AABB currBoundingBox, List<VoxelShape> voxelList, List<AABB> bbList) {
@@ -1635,7 +1652,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1717,7 +1729,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
double y = movement.y; double y = movement.y;
double z = movement.z; double z = movement.z;
@@ -229,31 +194,46 @@ index c1c1737bc7f57b7112567fe22a31c964cf4d10f7..ba94f23803adc9b83e46a7ed936e1780
if (y != 0.0) { if (y != 0.0) {
y = this.scanY(currBoundingBox, y, voxelList, bbList); y = this.scanY(currBoundingBox, y, voxelList, bbList);
@@ -1748,7 +1768,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1815,7 +1830,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return movement; ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER | this.getExtraCollisionFlags(), null // Sakura - load chunks on movement
} );
potentialCollisionsBB.addAll(entityAABBs);
- final Vec3 collided = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.performCollisions(movement, currentBox, potentialCollisionsVoxel, potentialCollisionsBB);
+ final Vec3 collided = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.performCollisions(movement, currentBox, potentialCollisionsVoxel, potentialCollisionsBB, this.physics); // Sakura - physics version api
- final Vec3 limitedMoveVector = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisionsVoxel, potentialCollisionsBB); final boolean collidedX = collided.x != movement.x;
+ final Vec3 limitedMoveVector = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisionsVoxel, potentialCollisionsBB, this.physics); // Sakura - physics version api final boolean collidedY = collided.y != movement.y;
@@ -1982,7 +1997,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
if (stepHeight > 0.0 private void checkInsideBlocks(List<Entity.Movement> queuedCollisionChecks, Set<BlockState> collidedBlocks) {
&& (onGround || (limitedMoveVector.y != movement.y && movement.y < 0.0)) if (this.isAffectedByBlocks()) {
@@ -1899,8 +1919,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - AABB axisalignedbb = this.getBoundingBox().deflate(9.999999747378752E-6D);
+ // Sakura start - physics version api
+ double offset = this.physics.afterOrEqual(1_21_2) ? 1.0E-5f : this.physics.afterOrEqual(1_19_3) ? 1.0E-7D : 0.001D;
+ AABB axisalignedbb = this.getBoundingBox().deflate(offset);
+ // Sakura end - physics version api
LongSet longset = this.visitedBlocks;
Iterator iterator = queuedCollisionChecks.iterator();
protected void checkInsideBlocks() { @@ -1990,7 +2008,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
AABB axisalignedbb = this.getBoundingBox(); Entity.Movement entity_b = (Entity.Movement) iterator.next();
- BlockPos blockposition = BlockPos.containing(axisalignedbb.minX + 1.0E-7D, axisalignedbb.minY + 1.0E-7D, axisalignedbb.minZ + 1.0E-7D); Vec3 vec3d = entity_b.from();
- BlockPos blockposition1 = BlockPos.containing(axisalignedbb.maxX - 1.0E-7D, axisalignedbb.maxY - 1.0E-7D, axisalignedbb.maxZ - 1.0E-7D); Vec3 vec3d1 = entity_b.to();
+ // Sakura start - physics version api - Iterator iterator1 = BlockGetter.boxTraverseBlocks(vec3d, vec3d1, axisalignedbb).iterator();
+ double offset = this.physics.afterOrEqual(1_19_3) ? 1.0E-7D : 0.001D; + // Sakura start - physics version api
+ BlockPos blockposition = BlockPos.containing(axisalignedbb.minX + offset, axisalignedbb.minY + offset, axisalignedbb.minZ + offset); + final Iterable<BlockPos> positions;
+ BlockPos blockposition1 = BlockPos.containing(axisalignedbb.maxX - offset, axisalignedbb.maxY - offset, axisalignedbb.maxZ - offset); + if (this.physics.afterOrEqual(1_21_2)) {
+ // Sakura end - physics version api + positions = BlockGetter.boxTraverseBlocks(vec3d, vec3d1, axisalignedbb);
+ } else {
+ positions = BlockPos.betweenClosed(axisalignedbb);
+ }
+ final Iterator iterator1 = positions.iterator();
+ // Sakura end - physics version api
if (this.level().hasChunksAt(blockposition, blockposition1)) { while (iterator1.hasNext()) {
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); BlockPos blockposition = (BlockPos) iterator1.next();
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java 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 92d8b64f18cf7ac854a021e06102dad9932bfba0..a08123d67a43f9de5706dda22f3b59979f673ac4 100644 index 890f1d6f8ad740afb0b30208f7cd42594e4c9d20..7ec7cfde4ce47a7f4a64e83fa49ed7287684d6a0 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -147,6 +147,8 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti @@ -147,6 +147,8 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
@@ -278,7 +258,7 @@ index 92d8b64f18cf7ac854a021e06102dad9932bfba0..a08123d67a43f9de5706dda22f3b5997
world.addFreshEntity(entityfallingblock, spawnReason); // CraftBukkit world.addFreshEntity(entityfallingblock, spawnReason); // CraftBukkit
return entityfallingblock; return entityfallingblock;
} }
@@ -198,10 +204,47 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti @@ -207,10 +213,47 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
return this.heightParity ? this.getY() : super.getEyeY(); return this.heightParity ? this.getY() : super.getEyeY();
} }
// Sakura end - configure cannon mechanics // Sakura end - configure cannon mechanics
@@ -327,7 +307,7 @@ index 92d8b64f18cf7ac854a021e06102dad9932bfba0..a08123d67a43f9de5706dda22f3b5997
} }
@Override @Override
@@ -211,6 +254,11 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti @@ -220,6 +263,11 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
} else { } else {
Block block = this.blockState.getBlock(); Block block = this.blockState.getBlock();
@@ -339,38 +319,38 @@ index 92d8b64f18cf7ac854a021e06102dad9932bfba0..a08123d67a43f9de5706dda22f3b5997
++this.time; ++this.time;
this.applyGravity(); this.applyGravity();
this.moveStripped(MoverType.SELF, this.getDeltaMovement()); // Sakura - optimise cannon entity movement this.moveStripped(MoverType.SELF, this.getDeltaMovement()); // Sakura - optimise cannon entity movement
@@ -225,8 +273,15 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti @@ -240,8 +288,15 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
} if (world instanceof ServerLevel) {
// Paper end - Configurable falling blocks height nerf ServerLevel worldserver = (ServerLevel) world;
this.handlePortal();
+ // Sakura start - physics version api
+ if (this.physics.before(1_12_0)) {
+ this.setDeltaMovement(this.getDeltaMovement().scale(0.98F));
+ }
if (!this.level().isClientSide && (this.isAlive() || this.forceTickAfterTeleportToDuplicate)) {
- 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.
+ BlockPos blockposition = this.physics.before(1_17_0) ? this.patchedBlockPosition() : this.blockPosition();
+ // Sakura end - physics version api
boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock;
boolean flag1 = flag && this.level().getFluidState(blockposition).is(FluidTags.WATER);
double d0 = this.getDeltaMovement().lengthSqr();
@@ -251,8 +306,11 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
} else {
BlockState iblockdata = this.level().getBlockState(blockposition);
- this.setDeltaMovement(this.getDeltaMovement().multiply(0.7D, -0.5D, 0.7D)); + // Sakura start - physics version api
- if (!iblockdata.is(Blocks.MOVING_PISTON)) { + if (this.physics.before(1_12_0)) {
+ // Sakura start - physics version api + this.setDeltaMovement(this.getDeltaMovement().scale(0.98F));
+ double friction = this.physics.before(1_14_0) ? 0.7F : 0.7D; + }
+ this.setDeltaMovement(this.getDeltaMovement().multiply(friction, -0.5D, friction)); if (this.isAlive() || this.forceTickAfterTeleportToDuplicate) {
+ if (!iblockdata.is(Blocks.MOVING_PISTON) && (flag1 || !this.physics.isWithin(1_9_0, 1_12_0) || this.isAbleToStackOnBlock())) { - BlockPos blockposition = this.blockPosition();
+ // Sakura end - physics version api + // Patching the floating point issue on modern versions can break some cannons that rely on it.
if (!this.cancelDrop) { + // However, it makes sense for legacy versions pre-1.17 before the world height change.
boolean flag2 = iblockdata.canBeReplaced((BlockPlaceContext) (new DirectionalPlaceContext(this.level(), blockposition, Direction.DOWN, ItemStack.EMPTY, Direction.UP))); + BlockPos blockposition = this.physics.before(1_17_0) ? this.patchedBlockPosition() : this.blockPosition();
boolean flag3 = FallingBlock.isFree(this.level().getBlockState(blockposition.below())) && (!flag || !flag1); + // Sakura end - physics version api
@@ -319,7 +377,12 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock;
boolean flag1 = flag && this.level().getFluidState(blockposition).is(FluidTags.WATER);
double d0 = this.getDeltaMovement().lengthSqr();
@@ -266,8 +321,11 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
} else {
BlockState iblockdata = this.level().getBlockState(blockposition);
- this.setDeltaMovement(this.getDeltaMovement().multiply(0.7D, -0.5D, 0.7D));
- if (!iblockdata.is(Blocks.MOVING_PISTON)) {
+ // Sakura start - physics version api
+ double friction = this.physics.before(1_14_0) ? 0.7F : 0.7D;
+ this.setDeltaMovement(this.getDeltaMovement().multiply(friction, -0.5D, friction));
+ if (!iblockdata.is(Blocks.MOVING_PISTON) && (flag1 || !this.physics.isWithin(1_9_0, 1_12_0) || this.isAbleToStackOnBlock())) {
+ // Sakura end - physics version api
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);
@@ -335,7 +393,12 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
} }
} }
@@ -385,10 +365,10 @@ index 92d8b64f18cf7ac854a021e06102dad9932bfba0..a08123d67a43f9de5706dda22f3b5997
} }
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java 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 4d0cfa1f96a04713cb1d51c7aaaf91374a0d6c17..96c43df6834e20a9e04eb095f36a644ec393c342 100644 index 3e4935f4a07fa14152d1f55f069c49fdd2f3bc02..1231d99374ffa5d988e5b240be2da95f0002947c 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -102,6 +102,13 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak @@ -108,6 +108,13 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
case Y -> this.setDeltaMovement(this.getDeltaMovement().multiply(0.0, 1.0, 0.0)); case Y -> this.setDeltaMovement(this.getDeltaMovement().multiply(0.0, 1.0, 0.0));
} }
// Sakura end - configure cannon mechanics // Sakura end - configure cannon mechanics
@@ -402,7 +382,7 @@ index 4d0cfa1f96a04713cb1d51c7aaaf91374a0d6c17..96c43df6834e20a9e04eb095f36a644e
} }
@Override @Override
@@ -134,10 +141,26 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak @@ -140,10 +147,26 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
} }
} }
// Sakura end - optimise tnt fluid state // Sakura end - optimise tnt fluid state
@@ -430,7 +410,7 @@ index 4d0cfa1f96a04713cb1d51c7aaaf91374a0d6c17..96c43df6834e20a9e04eb095f36a644e
} }
@Override @Override
@@ -152,15 +175,19 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak @@ -159,15 +182,19 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
return; return;
} }
// Paper end - Configurable TNT height nerf // Paper end - Configurable TNT height nerf
@@ -453,19 +433,20 @@ index 4d0cfa1f96a04713cb1d51c7aaaf91374a0d6c17..96c43df6834e20a9e04eb095f36a644e
// CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event
// this.discard(); // this.discard();
this.respawnEntity(); // Sakura - merge cannon entities this.respawnEntity(); // Sakura - merge cannon entities
@@ -213,7 +240,10 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak @@ -220,7 +247,11 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent((org.bukkit.entity.Explosive)this.getBukkitEntity()); if (event.isCancelled()) {
return;
if (!event.isCancelled()) {
- this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? PrimedTnt.USED_PORTAL_DAMAGE_CALCULATOR : null, 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, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? PrimedTnt.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), pos, this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.TNT);
+ // Sakura end - physics version api
} }
- this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? PrimedTnt.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.TNT);
+
+ // Sakura start - physics version api
+ double offsetY = this.physics.before(1_10_0) ? this.getY() + (double) 0.49f : this.getY(0.0625D);
+ this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? PrimedTnt.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), offsetY, this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.TNT);
+ // Sakura end - physics version api
// CraftBukkit end // CraftBukkit end
} }
@@ -289,7 +319,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
@@ -307,7 +338,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
// Paper start - Option to prevent TNT from moving in water // Paper start - Option to prevent TNT from moving in water
@Override @Override
public boolean isPushedByFluid() { public boolean isPushedByFluid() {
@@ -474,104 +455,11 @@ index 4d0cfa1f96a04713cb1d51c7aaaf91374a0d6c17..96c43df6834e20a9e04eb095f36a644e
} }
// Paper end - Option to prevent TNT from moving in water // Paper end - Option to prevent TNT from moving in water
} }
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index fa142719b1c4f6434466141128c475ef945edbb7..cfeacded13f5ebbc3ef66163387c7a40622d7b74 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -78,6 +78,7 @@ public class Explosion {
// CraftBukkit end
public boolean excludeSourceFromDamage = true; // Paper - Allow explosions to damage source
private final boolean consistentRadius; // Sakura - consistent explosion radius
+ protected final me.samsuik.sakura.physics.PhysicsVersion physics; // Sakura - physics version api
// Paper start - optimise collisions
private static final double[] CACHED_RAYS;
@@ -453,6 +454,7 @@ public class Explosion {
this.explosionSound = soundEvent;
this.yield = this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F; // CraftBukkit
this.consistentRadius = world.localConfig().config(BlockPos.containing(x, y, z)).consistentRadius; // Sakura - consistent explosion radius
+ this.physics = entity != null ? entity.physics() : world.localConfig().config(BlockPos.containing(x, y, z)).physicsVersion; // Sakura - physics version api
}
private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) {
@@ -484,8 +486,12 @@ public class Explosion {
final float density = entity.level().densityCache.getKnownDensity(vec3d1);
if (density != me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) {
hitResult = density != 0.0f ? net.minecraft.world.phys.HitResult.Type.MISS : net.minecraft.world.phys.HitResult.Type.BLOCK;
+ // Sakura start - physics version api
+ } else if (entity.physics().before(1_14_0)) {
+ hitResult = entity.level().clipLegacy(vec3d1, source);
} else {
- hitResult = entity.level().clip(new ClipContext(vec3d1, source, ClipContext.Block.COLLIDER, 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();
+ // Sakura end - physics version api
}
if (hitResult == HitResult.Type.MISS) {
// Sakura end - replace density cache
@@ -581,6 +587,14 @@ public class Explosion {
}
if (cachedBlock.outOfWorld) {
+ // Sakura start - physics version api
+ if (this.physics.before(1_17_0)) {
+ currX += incX;
+ currY += incY;
+ currZ += incZ;
+ continue;
+ }
+ // Sakura end - physics version api
break;
}
// Paper end - collision optimisations
@@ -683,9 +697,15 @@ public class Explosion {
if (d7 <= 1.0D) {
double d8 = entity.getX() - this.x;
- double d9 = (entity instanceof PrimedTnt ? entity.getY() : entity.getEyeY()) - this.y;
+ double d9 = entity.getEyeY() - this.y; // Sakura - physics version api
double d10 = entity.getZ() - this.z;
double d11 = Math.sqrt(d8 * d8 + d9 * d9 + d10 * d10);
+ // Sakura start - physics version api
+ if (this.physics.before(1_17_0)) {
+ d7 = (float) d7;
+ d11 = (float) d11;
+ }
+ // Sakura end - physics version api
if (d11 != 0.0D) {
d8 /= d11;
@@ -1015,7 +1035,7 @@ public class Explosion {
// Sakura start - replace density cache
float blockDensity = this.level.densityCache.getDensity(vec3d, entity);
if (blockDensity == me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) {
- blockDensity = this.getSeenFraction(vec3d, entity, blockCache, blockPos); // Paper - optimise explosions;
+ blockDensity = this.getSeenPercent(vec3d, entity, blockCache, blockPos); // Sakura - physics version api // Paper - optimise explosions;
this.level.densityCache.putDensity(vec3d, entity, blockDensity);
// Sakura end - replace density cache
}
@@ -1023,6 +1043,17 @@ public class Explosion {
return blockDensity;
}
+ // Sakura start - physics version api
+ private float getSeenPercent(Vec3 vec3d, Entity entity, ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[] blockCache, BlockPos.MutableBlockPos blockPos) {
+ if (this.physics.afterOrEqual(1_16_0)) {
+ // Papers impl is untouched, intended to be used as a fast path.
+ return this.getSeenFraction(vec3d, entity, blockCache, blockPos);
+ } else {
+ return getSeenPercent(vec3d, entity);
+ }
+ }
+ // Sakura end - physics version api
+
static class CacheKey {
private final Level world;
private final double posX, posY, posZ;
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 20d6044e32cc56089a175675ff74dca02d68e75a..bd72b02c20fb56c2351f865dfff2573545ac313a 100644 index 0ae2d83055252146e346b06cc8360eef56d39f5c..8c41282eafc1201bf1c0d001fb4fe791f3173f87 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -695,6 +695,170 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -841,6 +841,170 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
return chunk != null ? chunk.getNoiseBiome(x, y, z) : this.getUncachedNoiseBiome(x, y, z); return chunk != null ? chunk.getNoiseBiome(x, y, z) : this.getUncachedNoiseBiome(x, y, z);
} }
// Paper end - optimise random ticking // Paper end - optimise random ticking
@@ -742,17 +630,105 @@ index 20d6044e32cc56089a175675ff74dca02d68e75a..bd72b02c20fb56c2351f865dfff25735
public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities
public final me.samsuik.sakura.explosion.density.BlockDensityCache densityCache = new me.samsuik.sakura.explosion.density.BlockDensityCache(); // Sakura - explosion density cache public final me.samsuik.sakura.explosion.density.BlockDensityCache densityCache = new me.samsuik.sakura.explosion.density.BlockDensityCache(); // Sakura - explosion density cache
public final me.samsuik.sakura.explosion.durable.DurableBlockManager durabilityManager = new me.samsuik.sakura.explosion.durable.DurableBlockManager(); // Sakura - explosion durable blocks public final me.samsuik.sakura.explosion.durable.DurableBlockManager durabilityManager = new me.samsuik.sakura.explosion.durable.DurableBlockManager(); // Sakura - explosion durable blocks
diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java
index 1a912813ab7fa112379876ea1d4c903afe45c069..97debcf36d4aa3f8a6c83d35c53ba95342966fbf 100644
--- a/src/main/java/net/minecraft/world/level/ServerExplosion.java
+++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java
@@ -413,6 +413,7 @@ public class ServerExplosion implements Explosion {
}
// Sakura end - explosion durable blocks
private final boolean consistentRadius; // Sakura - consistent explosion radius
+ protected final me.samsuik.sakura.physics.PhysicsVersion physics; // Sakura - physics version api
public ServerExplosion(ServerLevel world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, Vec3 pos, float power, boolean createFire, Explosion.BlockInteraction destructionType) {
this.level = world;
@@ -425,6 +426,7 @@ public class ServerExplosion implements Explosion {
this.damageCalculator = behavior == null ? this.makeDamageCalculator(entity) : behavior;
this.yield = this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F; // CraftBukkit
this.consistentRadius = world.localConfig().config(BlockPos.containing(this.center)).consistentRadius; // Sakura - consistent explosion radius
+ this.physics = entity != null ? entity.physics() : world.localConfig().config(BlockPos.containing(this.center)).physicsVersion; // Sakura - physics version api
}
private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) {
@@ -456,8 +458,12 @@ public class ServerExplosion implements Explosion {
final float density = entity.level().densityCache.getKnownDensity(vec3d1);
if (density != me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) {
hitResult = density != 0.0f ? net.minecraft.world.phys.HitResult.Type.MISS : net.minecraft.world.phys.HitResult.Type.BLOCK;
+ // Sakura start - physics version api
+ } else if (entity.physics().before(1_14_0)) {
+ hitResult = entity.level().clipLegacy(vec3d1, pos);
} else {
- hitResult = entity.level().clip(new ClipContext(vec3d1, pos, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType();
+ hitResult = entity.level().clip(new ClipContext(vec3d1, pos, entity.physics().afterOrEqual(1_16_0) ? ClipContext.Block.COLLIDER : ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getType();
+ // Sakura end - physics version api
}
if (hitResult == HitResult.Type.MISS) {
// Sakura end - replace density cache
@@ -556,6 +562,14 @@ public class ServerExplosion implements Explosion {
}
if (cachedBlock.outOfWorld) {
+ // Sakura start - physics version api
+ if (this.physics.before(1_17_0)) {
+ currX += incX;
+ currY += incY;
+ currZ += incZ;
+ continue;
+ }
+ // Sakura end - physics version api
break;
}
final BlockState iblockdata = cachedBlock.blockState;
@@ -652,6 +666,12 @@ public class ServerExplosion implements Explosion {
double d2 = (entity instanceof PrimedTnt ? entity.getY() : entity.getEyeY()) - this.center.y;
double d3 = entity.getZ() - this.center.z;
double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3);
+ // Sakura start - physics version api
+ if (this.physics.before(1_17_0)) {
+ d0 = (float) d0;
+ d4 = (float) d4;
+ }
+ // Sakura end - physics version api
if (d4 != 0.0D) {
d1 /= d4;
@@ -958,7 +978,7 @@ public class ServerExplosion implements Explosion {
// Sakura start - replace density cache
float blockDensity = this.level.densityCache.getDensity(vec3d, entity);
if (blockDensity == me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) {
- blockDensity = this.getSeenFraction(vec3d, entity, this.directMappedBlockCache, this.mutablePos); // Paper - collision optimisations
+ blockDensity = this.sakura_getSeenPercent(vec3d, entity); // Sakura - physics version api
this.level.densityCache.putDensity(vec3d, entity, blockDensity);
// Sakura end - replace density cache
}
@@ -966,6 +986,16 @@ public class ServerExplosion implements Explosion {
return blockDensity;
}
+ // Sakura start - physics version api
+ private float sakura_getSeenPercent(Vec3 vec3d, Entity entity) {
+ if (this.physics.afterOrEqual(1_16_0)) {
+ return this.getSeenFraction(vec3d, entity, this.directMappedBlockCache, this.mutablePos); // Paper - collision optimisations
+ } else {
+ return getSeenPercent(vec3d, entity);
+ }
+ }
+ // Sakura end - physics version api
+
static class CacheKey {
private final Level world;
private final double posX, posY, posZ;
diff --git a/src/main/java/net/minecraft/world/level/block/FallingBlock.java b/src/main/java/net/minecraft/world/level/block/FallingBlock.java 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 1ea1232a5ba3e48eef3a139d6487c9a190155ebd..4cf5147c8b089c3fa5476a05501fae0d9afaf341 100644 index 3b15bff00aa5889608cd0cff686c8c300127893a..788a87531b82e321317e802581758cc514a6861b 100644
--- a/src/main/java/net/minecraft/world/level/block/FallingBlock.java --- a/src/main/java/net/minecraft/world/level/block/FallingBlock.java
+++ b/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 { @@ -45,6 +45,15 @@ public abstract class FallingBlock extends Block implements Fallable {
return super.updateShape(state, direction, neighborState, world, pos, neighborPos); return super.updateShape(state, world, tickView, pos, direction, neighborPos, neighborState, random);
} }
+ // Sakura start - physics version api + // Sakura start - physics version api
+ @Override + @Override
+ public void neighborChanged(BlockState state, Level world, BlockPos pos, Block block, BlockPos fromPos, boolean notify) { + public void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, net.minecraft.world.level.redstone.Orientation wireOrientation, boolean notify) {
+ if (world.localConfig().config(pos).physicsVersion.before(1_18_2)) { + if (world.localConfig().config(pos).physicsVersion.before(1_18_2)) {
+ world.scheduleTick(pos, this, this.getDelayAfterPlace()); + world.scheduleTick(pos, this, this.getDelayAfterPlace());
+ } + }
@@ -761,12 +737,12 @@ index 1ea1232a5ba3e48eef3a139d6487c9a190155ebd..4cf5147c8b089c3fa5476a05501fae0d
+ +
@Override @Override
protected void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { protected void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
if (isFree(world.getBlockState(pos.below())) && pos.getY() >= world.getMinBuildHeight()) { if (isFree(world.getBlockState(pos.below())) && pos.getY() >= world.getMinY()) {
diff --git a/src/main/java/net/minecraft/world/level/block/FenceGateBlock.java b/src/main/java/net/minecraft/world/level/block/FenceGateBlock.java 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 26ed17e433cbafbbf788231f27f296f08048adfe..40176223df11efd9cb63d2a9abc425fefa860d3f 100644 index 5201a11503362c2d43a9eee028613137ac9ae451..4be9bb2539f9bd4b95f3ebfcea934fdea85fdfe7 100644
--- a/src/main/java/net/minecraft/world/level/block/FenceGateBlock.java --- a/src/main/java/net/minecraft/world/level/block/FenceGateBlock.java
+++ b/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 { @@ -185,8 +185,13 @@ public class FenceGateBlock extends HorizontalDirectionalBlock {
} }
// CraftBukkit end // CraftBukkit end
@@ -777,16 +753,69 @@ index 26ed17e433cbafbbf788231f27f296f08048adfe..40176223df11efd9cb63d2a9abc425fe
+ final boolean powered = state.getValue(FenceGateBlock.POWERED); + final boolean powered = state.getValue(FenceGateBlock.POWERED);
+ if (legacy ? (flag1 || sourceBlock.defaultBlockState().isSignalSource()) : powered != flag1) { + if (legacy ? (flag1 || sourceBlock.defaultBlockState().isSignalSource()) : powered != flag1) {
+ final boolean openGate = legacy && (flag1 == powered || state.getValue(FenceGateBlock.OPEN) != powered) ? state.getValue(OPEN) : flag1; + final boolean openGate = legacy && (flag1 == powered || state.getValue(FenceGateBlock.OPEN) != powered) ? state.getValue(OPEN) : flag1;
+ world.setBlock(pos, (BlockState) ((BlockState) state.setValue(FenceGateBlock.POWERED, flag1)).setValue(FenceGateBlock.OPEN, openGate), 2); + world.setBlock(pos, (state.setValue(FenceGateBlock.POWERED, flag1)).setValue(FenceGateBlock.OPEN, openGate), 2);
+ // Sakura end - physics version api + // Sakura end - physics version api
if ((Boolean) state.getValue(FenceGateBlock.OPEN) != flag1) { if ((Boolean) state.getValue(FenceGateBlock.OPEN) != flag1) {
world.playSound((Player) null, pos, flag1 ? this.type.fenceGateOpen() : this.type.fenceGateClose(), SoundSource.BLOCKS, 1.0F, world.getRandom().nextFloat() * 0.1F + 0.9F); 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, (Holder) (flag1 ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE), pos); world.gameEvent((Entity) null, (Holder) (flag1 ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE), pos);
diff --git a/src/main/java/net/minecraft/world/level/block/HoneyBlock.java b/src/main/java/net/minecraft/world/level/block/HoneyBlock.java
index 5c360c6768582c1a35431739613e9b406875cc21..87c3a1a17db467714eaae19436cf65a00c16fede 100644
--- a/src/main/java/net/minecraft/world/level/block/HoneyBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/HoneyBlock.java
@@ -70,11 +70,19 @@ public class HoneyBlock extends HalfTransparentBlock {
super.entityInside(state, world, pos, entity);
}
- private static double getOldDeltaY(double d) {
+ // Sakura start - physics version api
+ private static double getOldDeltaY(double d, Entity entity) {
+ if (entity.physics().before(1_21_2)) {
+ return d;
+ }
return d / 0.98F + 0.08;
}
- private static double getNewDeltaY(double d) {
+ private static double getNewDeltaY(double d, Entity entity) {
+ if (entity.physics().before(1_21_2)) {
+ return d;
+ }
+ // Sakura end - physics version api
return (d - 0.08) * 0.98F;
}
@@ -83,7 +91,7 @@ public class HoneyBlock extends HalfTransparentBlock {
return false;
} else if (entity.getY() > (double)pos.getY() + 0.9375 - 1.0E-7) {
return false;
- } else if (getOldDeltaY(entity.getDeltaMovement().y) >= -0.08) {
+ } else if (getOldDeltaY(entity.getDeltaMovement().y, entity) >= -0.08) { // Sakura - physics version api
return false;
} else {
double d = Math.abs((double)pos.getX() + 0.5 - entity.getX());
@@ -101,11 +109,13 @@ public class HoneyBlock extends HalfTransparentBlock {
private void doSlideMovement(Entity entity) {
Vec3 vec3 = entity.getDeltaMovement();
- if (getOldDeltaY(entity.getDeltaMovement().y) < -0.13) {
- double d = -0.05 / getOldDeltaY(entity.getDeltaMovement().y);
- entity.setDeltaMovement(new Vec3(vec3.x * d, getNewDeltaY(-0.05), vec3.z * d));
+ // Sakura start - physics version api
+ if (getOldDeltaY(entity.getDeltaMovement().y, entity) < -0.13) {
+ double d = -0.05 / getOldDeltaY(entity.getDeltaMovement().y, entity);
+ entity.setDeltaMovement(new Vec3(vec3.x * d, getNewDeltaY(-0.05, entity), vec3.z * d));
} else {
- entity.setDeltaMovement(new Vec3(vec3.x, getNewDeltaY(-0.05), vec3.z));
+ entity.setDeltaMovement(new Vec3(vec3.x, getNewDeltaY(-0.05, entity), vec3.z));
+ // Sakura end - physics version api
}
entity.resetFallDistance();
diff --git a/src/main/java/net/minecraft/world/level/block/LadderBlock.java b/src/main/java/net/minecraft/world/level/block/LadderBlock.java 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 4b402a7222f78617ef7d28d329f4daac74954347..54781ea0771327f93a7cf672bb4b2945700c47e5 100644 index 2ac96a40a6d79a6291ebe3162b1e11a1cf0a88c0..f702c88e96f1f692074dc56f2212230d49db41fb 100644
--- a/src/main/java/net/minecraft/world/level/block/LadderBlock.java --- a/src/main/java/net/minecraft/world/level/block/LadderBlock.java
+++ b/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 { @@ -29,6 +29,21 @@ public class LadderBlock extends Block implements SimpleWaterloggedBlock {
protected static final VoxelShape WEST_AABB = Block.box(13.0, 0.0, 0.0, 16.0, 16.0, 16.0); protected static final VoxelShape WEST_AABB = Block.box(13.0, 0.0, 0.0, 16.0, 16.0, 16.0);
protected static final VoxelShape SOUTH_AABB = Block.box(0.0, 0.0, 0.0, 16.0, 16.0, 3.0); protected static final VoxelShape SOUTH_AABB = Block.box(0.0, 0.0, 0.0, 16.0, 16.0, 3.0);
protected static final VoxelShape NORTH_AABB = Block.box(0.0, 0.0, 13.0, 16.0, 16.0, 16.0); protected static final VoxelShape NORTH_AABB = Block.box(0.0, 0.0, 13.0, 16.0, 16.0, 16.0);
@@ -808,7 +837,7 @@ index 4b402a7222f78617ef7d28d329f4daac74954347..54781ea0771327f93a7cf672bb4b2945
@Override @Override
public MapCodec<LadderBlock> codec() { public MapCodec<LadderBlock> codec() {
@@ -39,8 +54,18 @@ public class LadderBlock extends Block implements SimpleWaterloggedBlock { @@ -40,8 +55,18 @@ public class LadderBlock extends Block implements SimpleWaterloggedBlock {
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(WATERLOGGED, Boolean.valueOf(false))); this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(WATERLOGGED, Boolean.valueOf(false)));
} }
@@ -828,10 +857,10 @@ index 4b402a7222f78617ef7d28d329f4daac74954347..54781ea0771327f93a7cf672bb4b2945
case NORTH: case NORTH:
return NORTH_AABB; 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 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 84623c632d8c2f0fa7ec939c711316d757117d23..afd6549f110ce32a1ad382b17f202ab53e7e6496 100644 index a2d023ff011f71f80032f02430a53d6a08a23623..9e0f4517069ee3fd16a60ccc214da68d518c7f85 100644
--- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java --- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
@@ -190,8 +190,26 @@ public class LiquidBlock extends Block implements BucketPickup { @@ -193,8 +193,26 @@ public class LiquidBlock extends Block implements BucketPickup {
BlockPos blockposition1 = pos.relative(enumdirection.getOpposite()); BlockPos blockposition1 = pos.relative(enumdirection.getOpposite());
if (world.getFluidState(blockposition1).is(FluidTags.WATER)) { if (world.getFluidState(blockposition1).is(FluidTags.WATER)) {
@@ -861,10 +890,10 @@ index 84623c632d8c2f0fa7ec939c711316d757117d23..afd6549f110ce32a1ad382b17f202ab5
if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, pos, block.defaultBlockState())) { if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, pos, block.defaultBlockState())) {
this.fizz(world, pos); 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 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 88ddd1747d9786210e8faf412b3b0363df4bab43..b6c3aa283b8c6dcd5af4f770301a5481af82f945 100644 index 2a3be00d41eda68f7d5383b240759561c4663f8d..0e579f0f32c908c8f2c799cb59cb4474ca002eb3 100644
--- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java --- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
@@ -699,6 +699,10 @@ public class RedStoneWireBlock extends Block { @@ -500,6 +500,10 @@ public class RedStoneWireBlock extends Block {
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) { protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
if (!player.getAbilities().mayBuild) { if (!player.getAbilities().mayBuild) {
return InteractionResult.PASS; return InteractionResult.PASS;
@@ -873,10 +902,10 @@ index 88ddd1747d9786210e8faf412b3b0363df4bab43..b6c3aa283b8c6dcd5af4f770301a5481
+ return InteractionResult.PASS; + return InteractionResult.PASS;
+ // Sakura end - physics version api + // Sakura end - physics version api
} else { } else {
if (RedStoneWireBlock.isCross(state) || RedStoneWireBlock.isDot(state)) { if (isCross(state) || isDot(state)) {
BlockState iblockdata1 = RedStoneWireBlock.isCross(state) ? this.defaultBlockState() : this.crossState; BlockState blockState = 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 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 932831bb5632ead5850842fc77192c841571162e..4300c421556b7a1e45812f54017a9b8435d33975 100644 index 72320c6099a4b26235bab68570e7b7efad84740f..737d4c96e9078504e1dd7c4ffd7812a37acb809e 100644
--- a/src/main/java/net/minecraft/world/level/block/WaterlilyBlock.java --- a/src/main/java/net/minecraft/world/level/block/WaterlilyBlock.java
+++ b/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 { @@ -21,6 +21,7 @@ public class WaterlilyBlock extends BushBlock {
@@ -907,10 +936,10 @@ index 932831bb5632ead5850842fc77192c841571162e..4300c421556b7a1e45812f54017a9b84
} }
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 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 f970fca8a8b479f2d2b927bcee2d73f02bfcd1b3..eeb7563ad312f048b02690fc9bfa2e00b1f1e845 100644 index b696597540d998c52ec3207ffd8bf658fde59215..485929a4e6e5600b799943fff19ab591dbe9ddc6 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java --- a/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java +++ b/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java
@@ -110,6 +110,17 @@ public class MovingPistonBlock extends BaseEntityBlock { @@ -109,6 +109,17 @@ public class MovingPistonBlock extends BaseEntityBlock {
@Override @Override
protected VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { protected VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
PistonMovingBlockEntity pistonMovingBlockEntity = this.getBlockEntity(world, pos); PistonMovingBlockEntity pistonMovingBlockEntity = this.getBlockEntity(world, pos);
@@ -929,10 +958,10 @@ index f970fca8a8b479f2d2b927bcee2d73f02bfcd1b3..eeb7563ad312f048b02690fc9bfa2e00
} }
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 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 e0c62227b279a5fe0f3868fbf9ce8c78c515a09c..4550217fdc3e804649b9c7e5e129680cae3ee0a5 100644 index 4b51472502d08ea357da437afeb4b581979e9cff..6146c786730b2cd5e5883acbe19d1eecff68e7e3 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java --- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
@@ -171,6 +171,11 @@ public class PistonBaseBlock extends DirectionalBlock { @@ -174,6 +174,11 @@ public class PistonBaseBlock extends DirectionalBlock {
// } // }
// PAIL: checkME - what happened to setTypeAndData? // PAIL: checkME - what happened to setTypeAndData?
// CraftBukkit end // CraftBukkit end
@@ -945,10 +974,10 @@ index e0c62227b279a5fe0f3868fbf9ce8c78c515a09c..4550217fdc3e804649b9c7e5e129680c
} }
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 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 bf58f33a5dc11b9e36cb9a26a73558c675a429df..30bbacceb253256fc083902512d5b6212a346315 100644 index c5c297b1081c9ddbb3bd0a0947401041aa8fec7d..d37c3ef71b1034ce2422c6078aa0abe79430cfac 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonHeadBlock.java --- a/src/main/java/net/minecraft/world/level/block/piston/PistonHeadBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonHeadBlock.java +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonHeadBlock.java
@@ -138,6 +138,11 @@ public class PistonHeadBlock extends DirectionalBlock { @@ -151,6 +151,11 @@ public class PistonHeadBlock extends DirectionalBlock {
@Override @Override
protected boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { protected boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
BlockState blockState = world.getBlockState(pos.relative(state.getValue(FACING).getOpposite())); BlockState blockState = world.getBlockState(pos.relative(state.getValue(FACING).getOpposite()));
@@ -960,10 +989,10 @@ index bf58f33a5dc11b9e36cb9a26a73558c675a429df..30bbacceb253256fc083902512d5b621
return this.isFittingBase(state, blockState) || blockState.is(Blocks.MOVING_PISTON) && blockState.getValue(FACING) == state.getValue(FACING); return this.isFittingBase(state, blockState) || blockState.is(Blocks.MOVING_PISTON) && blockState.getValue(FACING) == state.getValue(FACING);
} }
@@ -145,6 +150,10 @@ public class PistonHeadBlock extends DirectionalBlock { @@ -162,6 +167,10 @@ public class PistonHeadBlock extends DirectionalBlock {
protected void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) { sourceBlock,
if (state.canSurvive(world, pos)) { ExperimentalRedstoneUtils.withFront(wireOrientation, state.getValue(FACING).getOpposite())
world.neighborChanged(pos.relative(state.getValue(FACING).getOpposite()), sourceBlock, sourcePos); );
+ // Sakura start - physics version api + // Sakura start - physics version api
+ } else if (world.localConfig().config(pos).physicsVersion.before(1_9_0)) { + } else if (world.localConfig().config(pos).physicsVersion.before(1_9_0)) {
+ world.setBlock(pos, Blocks.AIR.defaultBlockState(), 19); + world.setBlock(pos, Blocks.AIR.defaultBlockState(), 19);
@@ -972,10 +1001,10 @@ index bf58f33a5dc11b9e36cb9a26a73558c675a429df..30bbacceb253256fc083902512d5b621
} }
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 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 d555ad1dd2f648b84920eceec6cc99e8801334b3..b2ecc615379856f661ba87bdeb28f75aa7d61602 100644 index f873061666cf7ba30b2b5dfe3b3a1ea85d2cdd4f..0b196a9a4b37fb432c0c965ee952742d59b43a13 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
@@ -164,6 +164,12 @@ public class PistonMovingBlockEntity extends BlockEntity { @@ -165,6 +165,12 @@ public class PistonMovingBlockEntity extends BlockEntity {
double i = 0.0; double i = 0.0;
@@ -988,7 +1017,7 @@ index d555ad1dd2f648b84920eceec6cc99e8801334b3..b2ecc615379856f661ba87bdeb28f75a
for (AABB aABB2 : list2) { for (AABB aABB2 : list2) {
AABB aABB3 = PistonMath.getMovementArea(moveByPositionAndProgress(pos, aABB2, blockEntity), direction, d); AABB aABB3 = PistonMath.getMovementArea(moveByPositionAndProgress(pos, aABB2, blockEntity), direction, d);
AABB aABB4 = entity.getBoundingBox(); AABB aABB4 = entity.getBoundingBox();
@@ -293,14 +299,167 @@ public class PistonMovingBlockEntity extends BlockEntity { @@ -298,18 +304,171 @@ public class PistonMovingBlockEntity extends BlockEntity {
} }
} }
} }
@@ -1137,6 +1166,10 @@ index d555ad1dd2f648b84920eceec6cc99e8801334b3..b2ecc615379856f661ba87bdeb28f75a
+ } + }
+ // Sakura end - physics version api + // Sakura end - physics version api
public Direction getPushDirection() {
return this.extending ? this.direction : this.direction.getOpposite();
}
public static void tick(Level world, BlockPos pos, BlockState state, PistonMovingBlockEntity blockEntity) { public static void tick(Level world, BlockPos pos, BlockState state, PistonMovingBlockEntity blockEntity) {
+ me.samsuik.sakura.physics.PhysicsVersion physicsVersion = world.localConfig().config(pos).physicsVersion; // Sakura - physics version api + me.samsuik.sakura.physics.PhysicsVersion physicsVersion = world.localConfig().config(pos).physicsVersion; // Sakura - physics version api
blockEntity.lastTicked = world.getGameTime(); blockEntity.lastTicked = world.getGameTime();
@@ -1156,7 +1189,7 @@ index d555ad1dd2f648b84920eceec6cc99e8801334b3..b2ecc615379856f661ba87bdeb28f75a
world.removeBlockEntity(pos); world.removeBlockEntity(pos);
blockEntity.setRemoved(); blockEntity.setRemoved();
if (world.getBlockState(pos).is(Blocks.MOVING_PISTON)) { if (world.getBlockState(pos).is(Blocks.MOVING_PISTON)) {
@@ -320,12 +479,23 @@ public class PistonMovingBlockEntity extends BlockEntity { @@ -331,12 +490,23 @@ public class PistonMovingBlockEntity extends BlockEntity {
} }
} else { } else {
float f = blockEntity.progress + 0.5F; float f = blockEntity.progress + 0.5F;
@@ -1181,23 +1214,23 @@ index d555ad1dd2f648b84920eceec6cc99e8801334b3..b2ecc615379856f661ba87bdeb28f75a
} }
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java 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 1c82ff348769655f20ba4fde7914a326e072afce..700226cc972693336987184c761c0c8808fd77ad 100644 index 4613162b6e716e33a838c59171c486b9c4d4b097..45127421ccbd4375c5408c27963ef2fa6e29de2a 100644
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java --- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java +++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
@@ -514,7 +514,7 @@ public abstract class FlowingFluid extends Fluid { @@ -560,7 +560,7 @@ public abstract class FlowingFluid extends Fluid {
this.spread(world, pos, state); this.spread(world, pos, blockState, fluidState);
} }
- protected static int getLegacyLevel(FluidState state) { - protected static int getLegacyLevel(FluidState state) {
+ public static int getLegacyLevel(FluidState state) { // Sakura - protected -> public + public static int getLegacyLevel(FluidState state) { // Sakura - physics version api; protected -> public
return state.isSource() ? 0 : 8 - Math.min(state.getAmount(), 8) + ((Boolean) state.getValue(FlowingFluid.FALLING) ? 8 : 0); return state.isSource() ? 0 : 8 - Math.min(state.getAmount(), 8) + ((Boolean) state.getValue(FlowingFluid.FALLING) ? 8 : 0);
} }
diff --git a/src/main/java/net/minecraft/world/level/material/LavaFluid.java b/src/main/java/net/minecraft/world/level/material/LavaFluid.java 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 3bb4a9a1a6249e8ba2de237f801210e7f4fd5825..65e4b4e16335e2e5be6e6a6a52f12f853040338d 100644 index 884db3e64cb22ed765beec8f11ea309fcf810207..e6ed1e46a4880743b7eeb73857b4b501971d6e29 100644
--- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java --- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java
+++ b/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 { @@ -176,7 +176,10 @@ public abstract class LavaFluid extends FlowingFluid {
@Override @Override
public boolean canBeReplacedWith(FluidState state, BlockGetter world, BlockPos pos, Fluid fluid, Direction direction) { public boolean canBeReplacedWith(FluidState state, BlockGetter world, BlockPos pos, Fluid fluid, Direction direction) {
@@ -1210,10 +1243,10 @@ index 3bb4a9a1a6249e8ba2de237f801210e7f4fd5825..65e4b4e16335e2e5be6e6a6a52f12f85
@Override @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 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 109f71401c65f476ccf6813137386fc9fef10254..8621e60b50cc27ef0b5468d978828c61f286be84 100644 index 552925ba47c7475e2e1ec2ded0966f28ed3e50a5..66b9a574eb57c6fb2964825ecca7110d079fb7cc 100644
--- a/src/main/java/net/minecraft/world/level/material/WaterFluid.java --- a/src/main/java/net/minecraft/world/level/material/WaterFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/WaterFluid.java +++ b/src/main/java/net/minecraft/world/level/material/WaterFluid.java
@@ -120,7 +120,10 @@ public abstract class WaterFluid extends FlowingFluid { @@ -121,7 +121,10 @@ public abstract class WaterFluid extends FlowingFluid {
@Override @Override
public boolean canBeReplacedWith(FluidState state, BlockGetter world, BlockPos pos, Fluid fluid, Direction direction) { public boolean canBeReplacedWith(FluidState state, BlockGetter world, BlockPos pos, Fluid fluid, Direction direction) {

View File

@@ -5,7 +5,7 @@ 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 diff --git a/src/main/java/net/minecraft/world/item/BucketItem.java b/src/main/java/net/minecraft/world/item/BucketItem.java
index 321188173918d0d60858a258400dfd682ccdb21c..229d71f093f672f323cc2feadf2cd174a62805f8 100644 index 3bddfb6f7412ab86e0c090d0cbc6cf254b3f891c..4cb809976b42af933401e8fc34ee43e181761558 100644
--- a/src/main/java/net/minecraft/world/item/BucketItem.java --- a/src/main/java/net/minecraft/world/item/BucketItem.java
+++ b/src/main/java/net/minecraft/world/item/BucketItem.java +++ b/src/main/java/net/minecraft/world/item/BucketItem.java
@@ -196,7 +196,7 @@ public class BucketItem extends Item implements DispensibleContainerItem { @@ -196,7 +196,7 @@ public class BucketItem extends Item implements DispensibleContainerItem {
@@ -18,10 +18,10 @@ index 321188173918d0d60858a258400dfd682ccdb21c..229d71f093f672f323cc2feadf2cd174
int j = blockposition.getY(); int j = blockposition.getY();
int k = blockposition.getZ(); 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 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 ac775afb265430ac202cfa3900a036d11a308b1e..d5b82bc2932fdb10304c6120dc692769c8288989 100644 index a94762e65853ccad38cf90b0049ca256106c0c9f..fac57b911966855c31dccc26cae7d7113da437dd 100644
--- a/src/main/java/net/minecraft/world/level/block/IceBlock.java --- a/src/main/java/net/minecraft/world/level/block/IceBlock.java
+++ b/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 { @@ -42,7 +42,7 @@ public class IceBlock extends HalfTransparentBlock {
public void afterDestroy(Level world, BlockPos pos, ItemStack tool) { public void afterDestroy(Level world, BlockPos pos, ItemStack tool) {
// Paper end - Improve Block#breakNaturally API // Paper end - Improve Block#breakNaturally API
if (!EnchantmentHelper.hasTag(tool, EnchantmentTags.PREVENTS_ICE_MELTING)) { if (!EnchantmentHelper.hasTag(tool, EnchantmentTags.PREVENTS_ICE_MELTING)) {
@@ -30,7 +30,7 @@ index ac775afb265430ac202cfa3900a036d11a308b1e..d5b82bc2932fdb10304c6120dc692769
world.removeBlock(pos, false); world.removeBlock(pos, false);
return; return;
} }
@@ -69,7 +69,7 @@ public class IceBlock extends HalfTransparentBlock { @@ -70,7 +70,7 @@ public class IceBlock extends HalfTransparentBlock {
return; return;
} }
// CraftBukkit end // CraftBukkit end

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 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 bb6bd75645d18933f6d1b5c68a33f28e30b5ac2d..89bdc1db40227ead1675645ec7711874a75ca9ca 100644 index 7ec7cfde4ce47a7f4a64e83fa49ed7287684d6a0..a41fef64424ae5419713e54af41f3d9622b64e89 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -282,7 +282,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti @@ -297,7 +297,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
// However, it makes sense for legacy versions pre-1.17 before the world height change. // However, it makes sense for legacy versions pre-1.17 before the world height change.
BlockPos blockposition = this.physics.before(1_17_0) ? this.patchedBlockPosition() : this.blockPosition(); BlockPos blockposition = this.physics.before(1_17_0) ? this.patchedBlockPosition() : this.blockPosition();
// Sakura end - physics version api // Sakura end - physics version api
- boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock; - boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock;
+ boolean flag = this.level().sakuraConfig().cannons.sand.concreteSolidifyInWater && this.blockState.getBlock() instanceof ConcretePowderBlock; // Sakura + 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 flag1 = flag && this.level().getFluidState(blockposition).is(FluidTags.WATER);
double d0 = this.getDeltaMovement().lengthSqr(); double d0 = this.getDeltaMovement().lengthSqr();

View File

@@ -5,10 +5,10 @@ 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 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 65e4b4e16335e2e5be6e6a6a52f12f853040338d..8de74ad65e9b9019d1b4ffc01c44783c1c769cf1 100644 index e6ed1e46a4880743b7eeb73857b4b501971d6e29..4132e26332e6e8e061f43867426291ec0aefe0a2 100644
--- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java --- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java
+++ b/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 { @@ -184,7 +184,7 @@ public abstract class LavaFluid extends FlowingFluid {
@Override @Override
public int getTickDelay(LevelReader world) { public int getTickDelay(LevelReader world) {

View File

@@ -4,11 +4,11 @@ Date: Sat, 25 Nov 2023 21:14:45 +0000
Subject: [PATCH] Allow explosions to destroy lava 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 diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java
index cfeacded13f5ebbc3ef66163387c7a40622d7b74..f39507dd7e0890446c9c16e6ae45d96302577253 100644 index 97debcf36d4aa3f8a6c83d35c53ba95342966fbf..0789f37ae89b22f9e3500b25cbe27ef853950b85 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java --- a/src/main/java/net/minecraft/world/level/ServerExplosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java
@@ -175,6 +175,11 @@ public class Explosion { @@ -407,6 +407,11 @@ public class ServerExplosion implements Explosion {
return Optional.of(ZERO_RESISTANCE); return Optional.of(ZERO_RESISTANCE);
} }
// Sakura end - destroy water logged blocks // Sakura end - destroy water logged blocks
@@ -19,12 +19,12 @@ index cfeacded13f5ebbc3ef66163387c7a40622d7b74..f39507dd7e0890446c9c16e6ae45d963
+ // Sakura end - allow explosions to destroy lava + // Sakura end - allow explosions to destroy lava
} }
return this.damageCalculator.getBlockExplosionResistance((Explosion)(Object)this, this.level, pos, blockState, fluidState); return this.damageCalculator.getBlockExplosionResistance(this, this.level, pos, blockState, fluidState);
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
index d0109633e8bdf109cfc9178963d7b6cf92f8b189..61d1e3b9033a00da7cccadfcab92f0b211c28b00 100644 index 99fd67a78539133adf78d65e2c520ff3dd260301..37ea7f464d6ea691fb0ec08319d03f89bb41cfee 100644
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java --- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -195,7 +195,7 @@ public abstract class BlockBehaviour implements FeatureElement { @@ -198,7 +198,7 @@ public abstract class BlockBehaviour implements FeatureElement {
}); });
} }

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 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 4c1f20fafdbd86011959cc2d4983b6c2f8e87a5f..f0c7b64fafbc9d19cc16a70f416df2bee6bb130c 100644 index 385da0585f409ee453f10d45f5837cdc09adc21b..da5b41ba5e5fea8e7bc0d40a880ce0f0778d5785 100644
--- a/src/main/java/net/minecraft/world/level/block/BubbleColumnBlock.java --- a/src/main/java/net/minecraft/world/level/block/BubbleColumnBlock.java
+++ b/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 { @@ -49,6 +49,7 @@ public class BubbleColumnBlock extends Block implements BucketPickup {
@Override @Override
protected void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { protected 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 - Add EntityInsideBlockEvent if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent

View File

@@ -5,42 +5,42 @@ Subject: [PATCH] Treat solid blocks as full when moving fast
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
index aa23d2665d5804e31b7c1b7021377010e74e4718..a93dc86f8c75e7021f42025d8f80c846598c2ca0 100644 index 613d2d90571546a482ba493fae5cbc7c69dd8f08..72b135bbd5eed8e3f94f815a7b7ee827a2f9a8e6 100644
--- a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java --- a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
@@ -1597,6 +1597,7 @@ public final class CollisionUtil { @@ -1933,6 +1933,7 @@ public final class CollisionUtil {
public static final int COLLISION_FLAG_CHECK_BORDER = 1 << 2; 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_CHECK_ONLY = 1 << 3;
public static final int COLLISION_FLAG_ADD_TICKET = 1 << 4; // Sakura - load chunks on movement public static final int COLLISION_FLAG_ADD_TICKET = 1 << 4; // Sakura - load chunks on movement
+ public static final int COLLISION_FLAG_FULL_BLOCKS = 1 << 5; // Sakura - treat solid blocks as full when moving fast + public static final int COLLISION_FLAG_FULL_BLOCKS = 1 << 5; // Sakura - treat solid blocks as full when moving fast
public static boolean getCollisionsForBlocksOrWorldBorder(final net.minecraft.world.level.Level world, final net.minecraft.world.entity.Entity entity, final net.minecraft.world.phys.AABB aabb, public static boolean getCollisionsForBlocksOrWorldBorder(final Level world, final Entity entity, final AABB aabb,
final java.util.List<net.minecraft.world.phys.shapes.VoxelShape> intoVoxel, final java.util.List<net.minecraft.world.phys.AABB> intoAABB, final List<VoxelShape> intoVoxel, final List<AABB> intoAABB,
@@ -1648,6 +1649,7 @@ public final class CollisionUtil { @@ -1984,6 +1985,7 @@ public final class CollisionUtil {
final boolean loadChunks = (collisionFlags & COLLISION_FLAG_LOAD_CHUNKS) != 0; final boolean loadChunks = (collisionFlags & COLLISION_FLAG_LOAD_CHUNKS) != 0;
final boolean addTicket = (collisionFlags & COLLISION_FLAG_ADD_TICKET) != 0; // Sakura final boolean addTicket = (collisionFlags & COLLISION_FLAG_ADD_TICKET) != 0; // Sakura - load chunks on movement
+ final boolean fullBlocks = (collisionFlags & COLLISION_FLAG_FULL_BLOCKS) != 0; // Sakura - treat solid blocks as full when moving fast + final boolean fullBlocks = (collisionFlags & COLLISION_FLAG_FULL_BLOCKS) != 0; // Sakura - treat solid blocks as full when moving fast
final net.minecraft.world.level.chunk.ChunkSource chunkSource = world.getChunkSource(); final ChunkSource chunkSource = world.getChunkSource();
for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) { for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) {
@@ -1688,7 +1690,7 @@ public final class CollisionUtil { @@ -2023,7 +2025,7 @@ public final class CollisionUtil {
continue; continue;
} }
- final boolean hasSpecial = ((ca.spottedleaf.moonrise.patches.block_counting.BlockCountingChunkSection)section).moonrise$getSpecialCollidingBlocks() != 0; - final boolean hasSpecial = ((BlockCountingChunkSection)section).moonrise$hasSpecialCollidingBlocks();
+ final boolean hasSpecial = !fullBlocks && ((ca.spottedleaf.moonrise.patches.block_counting.BlockCountingChunkSection)section).moonrise$getSpecialCollidingBlocks() != 0; // Sakura - treat solid blocks as full when moving fast + final boolean hasSpecial = !fullBlocks && ((BlockCountingChunkSection)section).moonrise$hasSpecialCollidingBlocks(); // Sakura - treat solid blocks as full when moving fast
final int sectionAdjust = !hasSpecial ? 1 : 0; final int sectionAdjust = !hasSpecial ? 1 : 0;
final net.minecraft.world.level.chunk.PalettedContainer<net.minecraft.world.level.block.state.BlockState> blocks = section.states; final PalettedContainer<BlockState> blocks = section.states;
@@ -1724,7 +1726,12 @@ public final class CollisionUtil { @@ -2059,7 +2061,12 @@ public final class CollisionUtil {
net.minecraft.world.phys.shapes.VoxelShape blockCollision = ((ca.spottedleaf.moonrise.patches.collisions.block.CollisionBlockState)blockData).moonrise$getConstantCollisionShape(); VoxelShape blockCollision = ((CollisionBlockState)blockData).moonrise$getConstantContextCollisionShape();
if (edgeCount == 0 || ((edgeCount != 1 || blockData.hasLargeCollisionShape()) && (edgeCount != 2 || blockData.getBlock() == net.minecraft.world.level.block.Blocks.MOVING_PISTON))) { if (edgeCount == 0 || ((edgeCount != 1 || blockData.hasLargeCollisionShape()) && (edgeCount != 2 || blockData.getBlock() == Blocks.MOVING_PISTON))) {
- if (blockCollision == null) { - if (blockCollision == null) {
+ // Sakura start - treat solid blocks as full when moving fast + // Sakura start - treat solid blocks as full when moving fast
+ // todo: move this logic above emptyCollisionShape and consider all blocks as a solid except scaffolding and liquids + // todo: move this logic above emptyCollisionShape and consider all blocks as a solid except scaffolding and liquids
+ if (fullBlocks && blockData.moonrise$getConstantCollisionAABB() != null) { + if (fullBlocks && blockData.moonrise$getConstantContextCollisionShape() != null) {
+ blockCollision = net.minecraft.world.phys.shapes.Shapes.block(); + blockCollision = net.minecraft.world.phys.shapes.Shapes.block();
+ } else if (blockCollision == null) { + } else if (blockCollision == null) {
+ // Sakura end - treat solid blocks as full when moving fast + // Sakura end - treat solid blocks as full when moving fast
@@ -48,10 +48,10 @@ index aa23d2665d5804e31b7c1b7021377010e74e4718..a93dc86f8c75e7021f42025d8f80c846
blockCollision = blockData.getCollisionShape(world, mutablePos, collisionShape); blockCollision = blockData.getCollisionShape(world, mutablePos, collisionShape);
} }
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 13f0184f5cf5687b3641d3e94625c0599ed2afb1..6d3e350635f978cadb56961121638e124a00a059 100644 index 671bd5aa322a1516776163827c0fc4c85c84615e..80451700fac1da06401097c80d416100dd331c31 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -564,6 +564,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -625,6 +625,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
flags |= ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_ADD_TICKET; flags |= ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_ADD_TICKET;
} }

View File

@@ -5,22 +5,23 @@ Subject: [PATCH] Reduce entity tracker player updates
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index e80e1d7ac52ef6f81dab85916f8107bc3e9339c6..47e1bec18c9bed6028b63ed6a1bcc66bcd4df238 100644 index dff0b8a1f2afcef21ca7e7aea3ee635826a2e9ef..44e897e9a4bcb75858e1d32b1095b2d4b70f2463 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -928,7 +928,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -974,7 +974,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
if (tracker == null) { if (tracker == null) {
continue; continue;
} }
- ((ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerTrackedEntity)tracker).moonrise$tick(((ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity)entity).moonrise$getChunkData().nearbyPlayers);
+ // Sakura start - reduce entity tracker player updates + // Sakura start - reduce entity tracker player updates
+ if (tracker.shouldUpdatePlayers()) { + if (tracker.shouldUpdatePlayers()) {
((ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerTrackedEntity)tracker).moonrise$tick(nearbyPlayers.getChunk(entity.chunkPosition())); + ((ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerTrackedEntity)tracker).moonrise$tick(((ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity)entity).moonrise$getChunkData().nearbyPlayers);
+ } + }
+ // Sakura end - reduce entity tracker player updates + // Sakura end - reduce entity tracker player updates
tracker.serverEntity.sendChanges(); if (((ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerTrackedEntity)tracker).moonrise$hasPlayers()
} || ((ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity)entity).moonrise$getChunkStatus().isOrAfter(FullChunkStatus.ENTITY_TICKING)) {
tracker.serverEntity.sendChanges();
@@ -1205,12 +1209,30 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1244,12 +1248,28 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return true; return true;
} }
// Sakura end - visibility api and command // Sakura end - visibility api and command
@@ -33,10 +34,8 @@ index e80e1d7ac52ef6f81dab85916f8107bc3e9339c6..47e1bec18c9bed6028b63ed6a1bcc66b
+ if (this.entity instanceof net.minecraft.world.entity.player.Player || this.entity.tickCount % this.playerUpdateInterval == 0) { + if (this.entity instanceof net.minecraft.world.entity.player.Player || this.entity.tickCount % this.playerUpdateInterval == 0) {
+ return true; + return true;
+ } + }
+
+ Vec3 lastPosition = this.entityPosition; + Vec3 lastPosition = this.entityPosition;
+ this.entityPosition = this.entity.position(); + this.entityPosition = this.entity.position();
+
+ return this.entity.position().distanceToSqr(lastPosition) >= (double) this.range / 2.0; + return this.entity.position().distanceToSqr(lastPosition) >= (double) this.range / 2.0;
+ } + }
+ // Sakura start - reduce entity tracker player updates + // Sakura start - reduce entity tracker player updates

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 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 afd6549f110ce32a1ad382b17f202ab53e7e6496..6640dd9041cc4567e53b8c6d6acc24851e932c78 100644 index 9e0f4517069ee3fd16a60ccc214da68d518c7f85..0ea609556d906df3eadd3df83bd4a7f85857a14e 100644
--- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java --- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
@@ -197,7 +197,15 @@ public class LiquidBlock extends Block implements BucketPickup { @@ -200,7 +200,15 @@ public class LiquidBlock extends Block implements BucketPickup {
if (fluidState.isSource()) { if (fluidState.isSource()) {
block = Blocks.OBSIDIAN; block = Blocks.OBSIDIAN;
} else { } else {
@@ -26,10 +26,10 @@ index afd6549f110ce32a1ad382b17f202ab53e7e6496..6640dd9041cc4567e53b8c6d6acc2485
// SANITY: In legacy a patch by paper removes the fluid level condition from vanilla. // SANITY: In legacy a patch by paper removes the fluid level condition from vanilla.
if (physics.afterOrEqual(1_16_0) || physics.isLegacy() 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 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 8de74ad65e9b9019d1b4ffc01c44783c1c769cf1..28a968e7738b37a4280d5019b5334e5e0303c5ae 100644 index 4132e26332e6e8e061f43867426291ec0aefe0a2..ce34bbe57c524964300b6086358fa456f9e6d3ca 100644
--- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java --- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java
+++ b/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 { @@ -178,7 +178,7 @@ public abstract class LavaFluid extends FlowingFluid {
public boolean canBeReplacedWith(FluidState state, BlockGetter world, BlockPos pos, Fluid fluid, Direction direction) { public boolean canBeReplacedWith(FluidState state, BlockGetter world, BlockPos pos, Fluid fluid, Direction direction) {
// Sakura start - physics version api // Sakura start - physics version api
return state.getHeight(world, pos) >= 0.44444445F && fluid.is(FluidTags.WATER) return state.getHeight(world, pos) >= 0.44444445F && fluid.is(FluidTags.WATER)
@@ -39,10 +39,10 @@ index 8de74ad65e9b9019d1b4ffc01c44783c1c769cf1..28a968e7738b37a4280d5019b5334e5e
} }
diff --git a/src/main/java/net/minecraft/world/level/material/WaterFluid.java b/src/main/java/net/minecraft/world/level/material/WaterFluid.java 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 8621e60b50cc27ef0b5468d978828c61f286be84..7a202194c9dff4225b80d17d7cc462b82bcdaeb0 100644 index 66b9a574eb57c6fb2964825ecca7110d079fb7cc..3fa9e6baab6b8a4f4b02ea5cbbb68d57a7f6888d 100644
--- a/src/main/java/net/minecraft/world/level/material/WaterFluid.java --- a/src/main/java/net/minecraft/world/level/material/WaterFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/WaterFluid.java +++ b/src/main/java/net/minecraft/world/level/material/WaterFluid.java
@@ -122,7 +122,7 @@ public abstract class WaterFluid extends FlowingFluid { @@ -123,7 +123,7 @@ public abstract class WaterFluid extends FlowingFluid {
public boolean canBeReplacedWith(FluidState state, BlockGetter world, BlockPos pos, Fluid fluid, Direction direction) { public boolean canBeReplacedWith(FluidState state, BlockGetter world, BlockPos pos, Fluid fluid, Direction direction) {
// Sakura start - physics version api // Sakura start - physics version api
return direction == Direction.DOWN && !fluid.is(FluidTags.WATER) return direction == Direction.DOWN && !fluid.is(FluidTags.WATER)

View File

@@ -5,7 +5,7 @@ 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 diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java
index f57e1b78204dff661ad5d3ee93a88a00330af2dc..80b00aef33059fa57cb6a63bc0593f8f80c383f3 100644 index 7de66aa435dd36899b80f4ecc64480680e474d94..90c87fabab274f6202a92150c4f1d5bfe9f5dad8 100644
--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java --- a/src/main/java/net/minecraft/world/level/BaseSpawner.java
+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java +++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java
@@ -51,7 +51,16 @@ public abstract class BaseSpawner { @@ -51,7 +51,16 @@ public abstract class BaseSpawner {

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Allow disabling random dispenser item selection
diff --git a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java diff --git a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
index 431fb6a658c6aac43b6f9dbd1f578b83f261a4e3..92bcba5fc21e39a54aa44d0b17c716acce6cc5bd 100644 index c7f1937b0f171eee967388ab4699703dcdcfbd2b..77d2c11d5a01a1f209336c62ac5153b5efadbfd3 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
@@ -74,8 +74,15 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity { @@ -74,8 +74,15 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity {

View File

@@ -5,10 +5,10 @@ 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 diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 0fed8714e1d01c6f584d6de00fba3635740298f6..7acb574bf1ca8de1ecd023e96ef9c0013118091d 100644 index d302b53d1d6052b4982fedb496b4d100f75bbe33..c477eb3ea41e7d7caa04179248f116f617317cbd 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -1815,6 +1815,12 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -1852,6 +1852,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
// Paper start // Paper start
if (this.dead) { // Paper if (this.dead) { // Paper

View File

@@ -5,10 +5,10 @@ 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 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 700226cc972693336987184c761c0c8808fd77ad..b0d1c86dbbe6b6f1b8ac8f531b5f3bc3669e232a 100644 index 45127421ccbd4375c5408c27963ef2fa6e29de2a..b45ef9f57bf52d8b05fb0f4f9e97d1f9af0c1716 100644
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java --- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java +++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
@@ -466,6 +466,10 @@ public abstract class FlowingFluid extends Fluid { @@ -514,6 +514,10 @@ public abstract class FlowingFluid extends Fluid {
if (block instanceof LiquidBlockContainer ifluidcontainer) { if (block instanceof LiquidBlockContainer ifluidcontainer) {
return ifluidcontainer.canPlaceLiquid((Player) null, world, pos, state, fluid); return ifluidcontainer.canPlaceLiquid((Player) null, world, pos, state, fluid);
@@ -17,5 +17,5 @@ index 700226cc972693336987184c761c0c8808fd77ad..b0d1c86dbbe6b6f1b8ac8f531b5f3bc3
+ return false; + return false;
+ // Sakura end + // Sakura end
} else { } 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; return true;
} }

View File

@@ -0,0 +1,22 @@
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 e50b64ba18fe8a4536b6f8aadca93064cd9f47f7..1a1203a93550cae95f2a82062e16fb21a779ee94 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -925,6 +925,11 @@ public abstract class Player extends LivingEntity {
@Override
public boolean isInvulnerableTo(ServerLevel world, DamageSource source) {
+ // Sakura start - allow disabling explosions hurting players
+ if (!this.level().sakuraConfig().cannons.explosion.explosionsHurtPlayers && source.is(DamageTypeTags.IS_EXPLOSION)) {
+ return true;
+ }
+ // Sakura end - allow disabling explosions hurting players
return super.isInvulnerableTo(world, source) ? true : (source.is(DamageTypeTags.IS_DROWNING) ? !world.getGameRules().getBoolean(GameRules.RULE_DROWNING_DAMAGE) : (source.is(DamageTypeTags.IS_FALL) ? !world.getGameRules().getBoolean(GameRules.RULE_FALL_DAMAGE) : (source.is(DamageTypeTags.IS_FIRE) ? !world.getGameRules().getBoolean(GameRules.RULE_FIRE_DAMAGE) : (source.is(DamageTypeTags.IS_FREEZING) ? !world.getGameRules().getBoolean(GameRules.RULE_FREEZE_DAMAGE) : false))));
}

View File

@@ -5,10 +5,10 @@ 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 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 1807da10d07d1f6e4ddbc0fa1b8da34a688d67c3..0eca342bb4ca5740f69ffc9a57a37308d77375ac 100644 index e07b79ef172095c1800c88342b3ac8dc7703aea2..35dab3806fab4d1fe0ba4246c2e8566d2952b8d6 100644
--- a/src/main/java/net/minecraft/world/entity/animal/IronGolem.java --- a/src/main/java/net/minecraft/world/entity/animal/IronGolem.java
+++ b/src/main/java/net/minecraft/world/entity/animal/IronGolem.java +++ b/src/main/java/net/minecraft/world/entity/animal/IronGolem.java
@@ -243,6 +243,20 @@ public class IronGolem extends AbstractGolem implements NeutralMob { @@ -237,6 +237,20 @@ public class IronGolem extends AbstractGolem implements NeutralMob {
} }

View File

@@ -0,0 +1,23 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
Date: Sun, 24 Dec 2023 11:20:10 +0000
Subject: [PATCH] Add explosions dropping items config
diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java
index 0789f37ae89b22f9e3500b25cbe27ef853950b85..ace34cc86061bb4c9b080c6e9bf912b1fe3533a6 100644
--- a/src/main/java/net/minecraft/world/level/ServerExplosion.java
+++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java
@@ -842,6 +842,12 @@ public class ServerExplosion implements Explosion {
});
}
+ // Sakura start - config for explosions dropping items
+ if (!this.level.sakuraConfig().cannons.explosion.explosionsDropItems) {
+ list1.clear();
+ }
+ // Sakura end - config for explosions dropping items
+
iterator = list1.iterator();
while (iterator.hasNext()) {

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 4c5779112c5e7b880627ecc446a295eeeadb396e..d2babdee314202c5f9795ea21866f6f79cda2eca 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -967,7 +967,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

@@ -6,10 +6,10 @@ Subject: [PATCH] Avoid searching for lava if throttled water flow speed is
diff --git a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java 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 6640dd9041cc4567e53b8c6d6acc24851e932c78..36ff185ce68348f42d83451d825fb9575136c8b8 100644 index 0ea609556d906df3eadd3df83bd4a7f85857a14e..6cc129afdb19e121e1abe8dc07f5cc2216c7b084 100644
--- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java --- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
@@ -145,7 +145,7 @@ public class LiquidBlock extends Block implements BucketPickup { @@ -148,7 +148,7 @@ public class LiquidBlock extends Block implements BucketPickup {
// Paper start - Configurable speed for water flowing over lava // Paper start - Configurable speed for water flowing over lava
public int getFlowSpeed(Level world, BlockPos blockposition) { public int getFlowSpeed(Level world, BlockPos blockposition) {

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 11:20:10 +0000
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 f39507dd7e0890446c9c16e6ae45d96302577253..98df890c88c6635566b5702080753f5cb0c20598 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -909,6 +909,11 @@ public class Explosion {
this.level.densityCache.invalidate();
}
// Sakura end - explosion density cache
+ // Sakura start - config for explosions dropping items
+ if (!level.sakuraConfig().cannons.explosion.explosionsDropItems) {
+ list.clear();
+ }
+ // Sakura end - config for explosions dropping items
Iterator iterator = list.iterator();
while (iterator.hasNext()) {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Calculate biome noise once per chunk section
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
index c3b1caa352b988ec44fa2b2eb0536517711f5460..c3b2997760ca044e745a2a000206445d60fedc2c 100644 index e4ae25c83ab9dd1aaa530a5456275ef63cdb8511..ee296175dba6f05f88e8dd585e72b83bd31defcd 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
@@ -268,12 +268,18 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ @@ -310,12 +310,18 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
public void fillBiomesFromNoise(BiomeResolver biomeSupplier, Climate.Sampler sampler, int x, int y, int z) { public void fillBiomesFromNoise(BiomeResolver biomeSupplier, Climate.Sampler sampler, int x, int y, int z) {
PalettedContainer<Holder<Biome>> datapaletteblock = this.biomes.recreate(); PalettedContainer<Holder<Biome>> datapaletteblock = this.biomes.recreate();

View File

@@ -0,0 +1,22 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
Date: Sun, 28 Jan 2024 20:30:09 +0000
Subject: [PATCH] Fix doEntityDrops gamerule preventing falling blocks from
breaking
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 a41fef64424ae5419713e54af41f3d9622b64e89..2d9e42465d4a8adf2095d3d23b29df29af3df00d 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -376,6 +376,10 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
this.callOnBrokenAfterFall(block, blockposition);
this.spawnAtLocation(worldserver, (ItemLike) block);
+ // Sakura start - fix the do entity drops gamerule
+ } else {
+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
+ // Sakura end - fix the do entity drops gamerule
}
} else {
this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause

View File

@@ -5,12 +5,12 @@ Subject: [PATCH] Add entity travel distance limits
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index d9495f6585c13ed2b1cdbe971a721d5b717920aa..2eb0d27a9fa7795f5b0973179a23a3edb61ef75a 100644 index a9315006379f7ab5b40cb6aba7ed82727afe3a5a..292ec3f8332631c6614e5ed25eeb82f9c2615a3b 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1256,6 +1256,11 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. @@ -1306,6 +1306,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(entity); // Paper - EAR 2
if (isActive) { // Paper - EAR 2 if (isActive) { // Paper - EAR 2
TimingHistory.activatedEntityTicks++;
entity.tick(); entity.tick();
+ // Sakura start - entity travel distance limits + // Sakura start - entity travel distance limits
+ if (entity.isPastTravelDistanceLimit()) { + if (entity.isPastTravelDistanceLimit()) {
@@ -19,12 +19,12 @@ index d9495f6585c13ed2b1cdbe971a721d5b717920aa..2eb0d27a9fa7795f5b0973179a23a3ed
+ // Sakura end - entity travel distance limits + // Sakura end - entity travel distance limits
entity.postTick(); // CraftBukkit entity.postTick(); // CraftBukkit
} else { entity.inactiveTick(); } // Paper - EAR 2 } else { entity.inactiveTick(); } // Paper - EAR 2
this.getProfiler().pop(); gameprofilerfiller.pop();
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 38bd2af86bf1c15bb8d062630e9853dea9d32deb..33ba8ba3168425268825c24f0d9b7c9778b5b292 100644 index 80451700fac1da06401097c80d416100dd331c31..17255cc9739392d23b5b55f2be5660fc56d538d5 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -619,6 +619,19 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -680,6 +680,19 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return this.physics; return this.physics;
} }
// Sakura end - physics version api // Sakura end - physics version api
@@ -44,7 +44,7 @@ index 38bd2af86bf1c15bb8d062630e9853dea9d32deb..33ba8ba3168425268825c24f0d9b7c97
public Entity(EntityType<?> type, Level world) { public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet(); this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -668,6 +681,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -732,6 +745,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
this.entityData = datawatcher_a.build(); this.entityData = datawatcher_a.build();
this.setPos(0.0D, 0.0D, 0.0D); this.setPos(0.0D, 0.0D, 0.0D);
this.eyeHeight = this.dimensions.eyeHeight(); this.eyeHeight = this.dimensions.eyeHeight();

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Configure potion speed and breaking inside entities
diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
index 5f7d152f41eb85f17bcded4bc8099b998e5a338b..81e2161c90001ea941611f1691160df089c1cf97 100644 index 6c2d4d6f3a36ab452dfd3c33f66e54f152906639..d0ebc66072b50e977a1cd2cca01bcfaf16495c7b 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
@@ -156,7 +156,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { @@ -173,7 +173,7 @@ public abstract class Projectile extends Entity implements TraceableEntity {
super.tick(); super.tick();
} }
@@ -18,7 +18,7 @@ index 5f7d152f41eb85f17bcded4bc8099b998e5a338b..81e2161c90001ea941611f1691160df0
if (entity != null) { if (entity != null) {
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java b/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java diff --git a/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java b/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java
index e43b3b37a3afc903f057d49d34339f8022274d3e..4ee08ec33bca0313e105053266cfe5345e3e324e 100644 index e09ffb062022263681148d93d7897feb4cc7e41b..1c6ad2e033b311c8c85c4cac37341f81a745c12c 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java --- a/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java
@@ -51,7 +51,14 @@ public final class ProjectileUtil { @@ -51,7 +51,14 @@ public final class ProjectileUtil {
@@ -38,32 +38,32 @@ index e43b3b37a3afc903f057d49d34339f8022274d3e..4ee08ec33bca0313e105053266cfe534
hitResult = hitResult2; hitResult = hitResult2;
} }
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
index 86c4b593a97431efd062b8c9d86bf92269c00536..6bab3cad31d230cff33e1fcdba715a698cd5c787 100644 index 9d79b193fe2a737a20d1709548b2cd6c454ff27b..df3f8d8fcdd23cc155d3bb156a8e6290497cb060 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java --- a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
@@ -64,6 +64,25 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie @@ -64,6 +64,25 @@ public class ThrownPotion extends ThrowableItemProjectile {
super(EntityType.POTION, x, y, z, world); public ThrownPotion(Level world, double x, double y, double z, ItemStack stack) {
super(EntityType.POTION, x, y, z, world, stack);
} }
+
+ // Sakura start - configure potion mechanics + // Sakura start - configure potion mechanics
+ @Override + @Override
+ public void shoot(double x, double y, double z, float speed, float divergence) { + public void shoot(double x, double y, double z, float speed, float divergence) {
+ super.shoot(x, y, z, speed, divergence); + super.shoot(x, y, z, speed, divergence);
+ +
+ net.minecraft.world.phys.Vec3 movement = getDeltaMovement(); + net.minecraft.world.phys.Vec3 movement = this.getDeltaMovement();
+ double moveX = movement.x * level().sakuraConfig().entity.thrownPotion.horizontalSpeed; + double moveX = movement.x * this.level().sakuraConfig().entity.thrownPotion.horizontalSpeed;
+ double moveY = movement.y * level().sakuraConfig().entity.thrownPotion.verticalSpeed; + double moveY = movement.y * this.level().sakuraConfig().entity.thrownPotion.verticalSpeed;
+ double moveZ = movement.z * level().sakuraConfig().entity.thrownPotion.horizontalSpeed; + double moveZ = movement.z * this.level().sakuraConfig().entity.thrownPotion.horizontalSpeed;
+ +
+ setDeltaMovement(moveX, moveY, moveZ); + this.setDeltaMovement(moveX, moveY, moveZ);
+ } + }
+ +
+ @Override + @Override
+ protected final boolean checkLeftOwner() { + protected boolean checkLeftOwner() {
+ return super.checkLeftOwner() || level().sakuraConfig().entity.thrownPotion.allowBreakingInsideEntities && tickCount >= 5; + return super.checkLeftOwner() || this.level().sakuraConfig().entity.thrownPotion.allowBreakingInsideEntities && this.tickCount >= 5;
+ } + }
+ // Sakura end - configure potion mechanics + // Sakura end - configure potion mechanics
+
@Override @Override
protected Item getDefaultItem() { protected Item getDefaultItem() {
return Items.SPLASH_POTION;

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Add outline colliison to enderpearls
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java
index bf4c1883a1257af89428d6580a177f3af3759ee7..e0543e0e7959c67df4f9c06d45d03de829d1c379 100644 index c309198d092fdae6bdcc5d773b7b707bab2738bd..b0e15d97514da292a97d0bbfd0c522fa8b57ab0f 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java --- a/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java
@@ -40,10 +40,16 @@ public abstract class ThrowableProjectile extends Projectile { @@ -44,12 +44,18 @@ public abstract class ThrowableProjectile extends Projectile {
return true; return true;
} }
@@ -20,17 +20,19 @@ index bf4c1883a1257af89428d6580a177f3af3759ee7..e0543e0e7959c67df4f9c06d45d03de8
+ +
@Override @Override
public void tick() { public void tick() {
super.tick(); this.handleFirstTickBubbleColumn();
this.applyGravity();
this.applyInertia();
- HitResult movingobjectposition = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity); - HitResult movingobjectposition = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity);
+ HitResult movingobjectposition = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity, this.getClipType()); // Sakura - enderpearls use outline for collision + HitResult movingobjectposition = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity, this.getClipType()); // Sakura - enderpearls use outline for collision
Vec3 vec3d;
if (movingobjectposition.getType() != HitResult.Type.MISS) { if (movingobjectposition.getType() != HitResult.Type.MISS) {
this.preHitTargetOrDeflectSelf(movingobjectposition); // CraftBukkit - projectile hit event
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
index 1aa5e57a4e6a4be60514d8808a2e6c973d93e798..0dab87b1da300342870a95a1e50486e07f5b3ec8 100644 index bd2684528157f928460f2143dd71a48e11983123..59e55f1cd9a1bcfee657ec355007b1894301348c 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java --- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
@@ -123,6 +123,13 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { @@ -210,6 +210,13 @@ public class ThrownEnderpearl extends ThrowableItemProjectile {
} }
} }
@@ -43,4 +45,4 @@ index 1aa5e57a4e6a4be60514d8808a2e6c973d93e798..0dab87b1da300342870a95a1e50486e0
+ +
@Override @Override
public void tick() { public void tick() {
Entity entity = this.getOwner(); int i;

View File

@@ -1,29 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
Date: Sun, 28 Jan 2024 20:30:09 +0000
Subject: [PATCH] Fix doEntityDrops gamerule preventing falling blocks from
breaking
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 89bdc1db40227ead1675645ec7711874a75ca9ca..00f35010f927cfbe7e41131b1404b7ca92ebf6bd 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -357,10 +357,14 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
tileentity.setChanged();
}
}
- } else if (this.dropItem && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
+ // Sakura start - fix the do entity drops gamerule
+ } else {
this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
- this.callOnBrokenAfterFall(block, blockposition);
- this.spawnAtLocation((ItemLike) block);
+ if (this.dropItem && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
+ this.callOnBrokenAfterFall(block, blockposition);
+ this.spawnAtLocation((ItemLike) block);
+ }
+ // Sakura end
}
} else {
this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Disable player poses shrinking collision box
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java 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 d2babdee314202c5f9795ea21866f6f79cda2eca..5c3bebf932b6f0376711a2bd679062575bff04a3 100644 index 1a1203a93550cae95f2a82062e16fb21a779ee94..16f6834b88bf0b2f2157e25240e6bc51db501dce 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java --- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -2301,7 +2301,13 @@ public abstract class Player extends LivingEntity { @@ -2246,7 +2246,13 @@ public abstract class Player extends LivingEntity {
@Override @Override
public EntityDimensions getDefaultDimensions(Pose pose) { public EntityDimensions getDefaultDimensions(Pose pose) {

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Mob spawner behaviour
diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java
index 80b00aef33059fa57cb6a63bc0593f8f80c383f3..937c8b7db6b72cb89859a81386b1df80d4f3e6ef 100644 index 90c87fabab274f6202a92150c4f1d5bfe9f5dad8..4bc3a51116f95e924ccc5187a1ad7674ac3a97fc 100644
--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java --- a/src/main/java/net/minecraft/world/level/BaseSpawner.java
+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java +++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java
@@ -68,7 +68,7 @@ public abstract class BaseSpawner { @@ -68,7 +68,7 @@ public abstract class BaseSpawner {
@@ -21,8 +21,8 @@ index 80b00aef33059fa57cb6a63bc0593f8f80c383f3..937c8b7db6b72cb89859a81386b1df80
if (!mobspawnerdata_a.isValidPosition(blockposition1, world)) { if (!mobspawnerdata_a.isValidPosition(blockposition1, world)) {
continue; continue;
} }
- } else if (!SpawnPlacements.checkSpawnRules((EntityType) optional.get(), world, MobSpawnType.SPAWNER, blockposition1, world.getRandom())) { - } else if (!SpawnPlacements.checkSpawnRules((EntityType) optional.get(), world, EntitySpawnReason.SPAWNER, blockposition1, world.getRandom())) {
+ } else if (world.sakuraConfig().environment.mobSpawner.checkSpawnConditions && !SpawnPlacements.checkSpawnRules((EntityType) optional.get(), world, MobSpawnType.SPAWNER, blockposition1, world.getRandom())) { // Sakura - mob spawner behaviour + } else if (world.sakuraConfig().environment.mobSpawner.checkSpawnConditions && !SpawnPlacements.checkSpawnRules((EntityType) optional.get(), world, EntitySpawnReason.SPAWNER, blockposition1, world.getRandom())) { // Sakura - mob spawner behaviour
continue; continue;
} }
// Paper start - PreCreatureSpawnEvent // Paper start - PreCreatureSpawnEvent
@@ -39,8 +39,8 @@ index 80b00aef33059fa57cb6a63bc0593f8f80c383f3..937c8b7db6b72cb89859a81386b1df80
if (entity instanceof Mob) { if (entity instanceof Mob) {
Mob entityinsentient = (Mob) entity; Mob entityinsentient = (Mob) entity;
- if (mobspawnerdata.getCustomSpawnRules().isEmpty() && !entityinsentient.checkSpawnRules(world, MobSpawnType.SPAWNER) || !entityinsentient.checkSpawnObstruction(world)) { - if (mobspawnerdata.getCustomSpawnRules().isEmpty() && !entityinsentient.checkSpawnRules(world, EntitySpawnReason.SPAWNER) || !entityinsentient.checkSpawnObstruction(world)) {
+ if (world.sakuraConfig().environment.mobSpawner.checkSpawnConditions && (mobspawnerdata.getCustomSpawnRules().isEmpty() && !entityinsentient.checkSpawnRules(world, MobSpawnType.SPAWNER) || !entityinsentient.checkSpawnObstruction(world))) { // Sakura - mob spawner behaviour + if (world.sakuraConfig().environment.mobSpawner.checkSpawnConditions && (mobspawnerdata.getCustomSpawnRules().isEmpty() && !entityinsentient.checkSpawnRules(world, EntitySpawnReason.SPAWNER) || !entityinsentient.checkSpawnObstruction(world))) { // Sakura - mob spawner behaviour
continue; continue;
} }

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Use random chance for crop growth instead of age
diff --git a/src/main/java/net/minecraft/world/level/block/CactusBlock.java b/src/main/java/net/minecraft/world/level/block/CactusBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/CactusBlock.java b/src/main/java/net/minecraft/world/level/block/CactusBlock.java
index ff4dda48116a2969704b355ff96407ba869b466e..1722cf05a980beb5f83e866cfc7aabecbd67a1ad 100644 index c045b1cccf0047dbef8c04d5a28d31d53389054f..02da342fa002af134a75a9d2046e43808b76fbcc 100644
--- a/src/main/java/net/minecraft/world/level/block/CactusBlock.java --- a/src/main/java/net/minecraft/world/level/block/CactusBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CactusBlock.java +++ b/src/main/java/net/minecraft/world/level/block/CactusBlock.java
@@ -52,6 +52,19 @@ public class CactusBlock extends Block { @@ -53,6 +53,19 @@ public class CactusBlock extends Block {
@Override @Override
protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
@@ -28,21 +28,21 @@ index ff4dda48116a2969704b355ff96407ba869b466e..1722cf05a980beb5f83e866cfc7aabec
BlockPos blockposition1 = pos.above(); BlockPos blockposition1 = pos.above();
if (world.isEmptyBlock(blockposition1)) { if (world.isEmptyBlock(blockposition1)) {
@@ -68,7 +81,11 @@ public class CactusBlock extends Block { @@ -69,7 +82,11 @@ public class CactusBlock extends Block {
if (j >= 15 || (modifier != 100 && random.nextFloat() < (modifier / (100.0f * 16)))) { // Spigot - SPIGOT-7159: Better modifier resolution if (j >= 15 || (modifier != 100 && random.nextFloat() < (modifier / (100.0f * 16)))) { // Spigot - SPIGOT-7159: Better modifier resolution
CraftEventFactory.handleBlockGrowEvent(world, blockposition1, this.defaultBlockState()); // CraftBukkit CraftEventFactory.handleBlockGrowEvent(world, blockposition1, this.defaultBlockState()); // CraftBukkit
BlockState iblockdata1 = (BlockState) state.setValue(CactusBlock.AGE, 0); BlockState iblockdata1 = (BlockState) state.setValue(CactusBlock.AGE, 0);
- -
+ // Sakura start - use random chance for crop growth + // Sakura start - use random chance for crop growth
+ if (world.sakuraConfig().environment.crops.useRandomChanceToGrow) { + if (world.sakuraConfig().environment.crops.useRandomChanceToGrow) {
+ world.neighborShapeChanged(Direction.UP, state, blockposition1, pos, 4, 1); + world.neighborShapeChanged(Direction.UP, blockposition1, pos, state, 4, 1);
+ } + }
+ // Sakura end - use random chance for crop growth + // Sakura end - use random chance for crop growth
world.setBlock(pos, iblockdata1, 4); world.setBlock(pos, iblockdata1, 4);
world.neighborChanged(iblockdata1, blockposition1, this, pos, false); world.neighborChanged(iblockdata1, blockposition1, this, (Orientation) null, false);
} else if (modifier == 100 || random.nextFloat() < (modifier / (100.0f * 16))) { // Spigot - SPIGOT-7159: Better modifier resolution } else if (modifier == 100 || random.nextFloat() < (modifier / (100.0f * 16))) { // Spigot - SPIGOT-7159: Better modifier resolution
diff --git a/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java b/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java b/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java
index c48c622e92cedeaa46b929c7adfedec98dd5a3fb..38e91c4eb831810c27c31e3c5fa6c8b9c7cac0f3 100644 index 547ea09ed84595286c97c128b3b96f6d387ae25f..3db03582e710f87c176ec47d9cab901d27db2e5e 100644
--- a/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java --- a/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java +++ b/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java
@@ -52,6 +52,19 @@ public class SugarCaneBlock extends Block { @@ -52,6 +52,19 @@ public class SugarCaneBlock extends Block {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Protect block shapes against plugins
diff --git a/src/main/java/net/minecraft/world/level/block/CarpetBlock.java b/src/main/java/net/minecraft/world/level/block/CarpetBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/CarpetBlock.java b/src/main/java/net/minecraft/world/level/block/CarpetBlock.java
index 0cc3df1f8a7784af812a1519e0a508b67314ce9a..ab606a3ba037223898f1d947083aeeed13afdc4c 100644 index fe2d445a62fbd25d8dbbfad781bbf5a30e30175b..6b8e5ab4cf96865d608483e573d7bb809ac0b18a 100644
--- a/src/main/java/net/minecraft/world/level/block/CarpetBlock.java --- a/src/main/java/net/minecraft/world/level/block/CarpetBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CarpetBlock.java +++ b/src/main/java/net/minecraft/world/level/block/CarpetBlock.java
@@ -14,6 +14,7 @@ import net.minecraft.world.phys.shapes.VoxelShape; @@ -15,6 +15,7 @@ import net.minecraft.world.phys.shapes.VoxelShape;
public class CarpetBlock extends Block { public class CarpetBlock extends Block {
public static final MapCodec<CarpetBlock> CODEC = simpleCodec(CarpetBlock::new); public static final MapCodec<CarpetBlock> CODEC = simpleCodec(CarpetBlock::new);
protected static final VoxelShape SHAPE = Block.box(0.0, 0.0, 0.0, 16.0, 1.0, 16.0); protected static final VoxelShape SHAPE = Block.box(0.0, 0.0, 0.0, 16.0, 1.0, 16.0);
@@ -16,7 +16,7 @@ index 0cc3df1f8a7784af812a1519e0a508b67314ce9a..ab606a3ba037223898f1d947083aeeed
@Override @Override
public MapCodec<? extends CarpetBlock> codec() { public MapCodec<? extends CarpetBlock> codec() {
@@ -26,7 +27,7 @@ public class CarpetBlock extends Block { @@ -27,7 +28,7 @@ public class CarpetBlock extends Block {
@Override @Override
protected VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { protected VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
@@ -26,10 +26,10 @@ index 0cc3df1f8a7784af812a1519e0a508b67314ce9a..ab606a3ba037223898f1d947083aeeed
@Override @Override
diff --git a/src/main/java/net/minecraft/world/level/block/LadderBlock.java b/src/main/java/net/minecraft/world/level/block/LadderBlock.java 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 54781ea0771327f93a7cf672bb4b2945700c47e5..b03783b02176aad08123acf1fba2cf39daa5a0f2 100644 index f702c88e96f1f692074dc56f2212230d49db41fb..f022aa201e25da7c5a3c7195662c202cc1b57695 100644
--- a/src/main/java/net/minecraft/world/level/block/LadderBlock.java --- a/src/main/java/net/minecraft/world/level/block/LadderBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LadderBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LadderBlock.java
@@ -28,6 +28,12 @@ public class LadderBlock extends Block implements SimpleWaterloggedBlock { @@ -29,6 +29,12 @@ public class LadderBlock extends Block implements SimpleWaterloggedBlock {
protected static final VoxelShape WEST_AABB = Block.box(13.0, 0.0, 0.0, 16.0, 16.0, 16.0); protected static final VoxelShape WEST_AABB = Block.box(13.0, 0.0, 0.0, 16.0, 16.0, 16.0);
protected static final VoxelShape SOUTH_AABB = Block.box(0.0, 0.0, 0.0, 16.0, 16.0, 3.0); protected static final VoxelShape SOUTH_AABB = Block.box(0.0, 0.0, 0.0, 16.0, 16.0, 3.0);
protected static final VoxelShape NORTH_AABB = Block.box(0.0, 0.0, 13.0, 16.0, 16.0, 16.0); protected static final VoxelShape NORTH_AABB = Block.box(0.0, 0.0, 13.0, 16.0, 16.0, 16.0);
@@ -42,7 +42,7 @@ index 54781ea0771327f93a7cf672bb4b2945700c47e5..b03783b02176aad08123acf1fba2cf39
// Sakura start - physics version api // Sakura start - physics version api
protected static final VoxelShape LEGACY_EAST_AABB = Block.box(0.0, 0.0, 0.0, 2.0, 16.0, 16.0); protected static final VoxelShape LEGACY_EAST_AABB = Block.box(0.0, 0.0, 0.0, 2.0, 16.0, 16.0);
protected static final VoxelShape LEGACY_WEST_AABB = Block.box(14.0, 0.0, 0.0, 16.0, 16.0, 16.0); protected static final VoxelShape LEGACY_WEST_AABB = Block.box(14.0, 0.0, 0.0, 16.0, 16.0, 16.0);
@@ -68,14 +74,16 @@ public class LadderBlock extends Block implements SimpleWaterloggedBlock { @@ -69,14 +75,16 @@ public class LadderBlock extends Block implements SimpleWaterloggedBlock {
// Sakura end - physics version api // Sakura end - physics version api
switch ((Direction)state.getValue(FACING)) { switch ((Direction)state.getValue(FACING)) {
case NORTH: case NORTH:
@@ -64,20 +64,20 @@ index 54781ea0771327f93a7cf672bb4b2945700c47e5..b03783b02176aad08123acf1fba2cf39
} }
diff --git a/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java b/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java 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 11824d39e72fa003b3a56aa9b8d679fe8e23a1a4..132dd7028384126cef5d1d404adee4fbdec4c31b 100644 index 3f8e7e29c3e52211a29e6f0a32890f6b53bfd9a8..21210877f903323fbff961e9dd7f6eafb6f0a746 100644
--- a/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java --- a/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java
+++ b/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java +++ b/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java
@@ -539,6 +539,13 @@ public abstract class VoxelShape implements ca.spottedleaf.moonrise.patches.coll @@ -557,6 +557,13 @@ public abstract class VoxelShape implements ca.spottedleaf.moonrise.patches.coll
return this.isEmpty; // Paper - optimise collisions return this.isEmpty; // Paper - optimise collisions
} }
+ // Sakura start - protect block shapes against plugins + // Sakura start - protect block shapes against plugins
+ public final VoxelShape copy() { + public final VoxelShape copy() {
+ this.cachedToAABBs = null; + this.cachedToAABBs = null;
+ return this.move(0.0, 0.0, 0.0); + return this.move(Vec3.ZERO);
+ } + }
+ // Sakura end - protect block shapes against plugins + // Sakura end - protect block shapes against plugins
+ +
public VoxelShape move(double x, double y, double z) { public VoxelShape move(Vec3 vec3d) {
// Paper start - optimise collisions return this.move(vec3d.x, vec3d.y, vec3d.z);
if (this.isEmpty) { }

View File

@@ -4,21 +4,18 @@ Date: Fri, 23 Feb 2024 01:48:08 +0000
Subject: [PATCH] Legacy player combat mechanics Subject: [PATCH] Legacy player combat mechanics
diff --git a/src/main/java/me/samsuik/sakura/utils/CombatUtil.java b/src/main/java/me/samsuik/sakura/utils/CombatUtil.java diff --git a/src/main/java/me/samsuik/sakura/player/combat/CombatUtil.java b/src/main/java/me/samsuik/sakura/player/combat/CombatUtil.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..9c58f13396609ddd2bf7a909f2f20bd6bde27a1e index 0000000000000000000000000000000000000000..e0aa768656081fac2c87ff573b61584dc4c1a9a3
--- /dev/null --- /dev/null
+++ b/src/main/java/me/samsuik/sakura/utils/CombatUtil.java +++ b/src/main/java/me/samsuik/sakura/player/combat/CombatUtil.java
@@ -0,0 +1,90 @@ @@ -0,0 +1,64 @@
+package me.samsuik.sakura.utils; +package me.samsuik.sakura.player.combat;
+ +
+import it.unimi.dsi.fastutil.objects.Reference2FloatMap;
+import it.unimi.dsi.fastutil.objects.Reference2FloatOpenHashMap;
+import net.minecraft.core.Holder; +import net.minecraft.core.Holder;
+import net.minecraft.core.HolderLookup; +import net.minecraft.core.HolderLookup;
+import net.minecraft.core.RegistryAccess; +import net.minecraft.core.RegistryAccess;
+import net.minecraft.core.component.DataComponents; +import net.minecraft.core.component.DataComponents;
+import net.minecraft.core.registries.BuiltInRegistries;
+import net.minecraft.core.registries.Registries; +import net.minecraft.core.registries.Registries;
+import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceKey;
+import net.minecraft.server.MinecraftServer; +import net.minecraft.server.MinecraftServer;
@@ -35,32 +32,9 @@ index 0000000000000000000000000000000000000000..9c58f13396609ddd2bf7a909f2f20bd6
+import net.minecraft.world.item.enchantment.ItemEnchantments; +import net.minecraft.world.item.enchantment.ItemEnchantments;
+import org.apache.commons.lang3.mutable.MutableFloat; +import org.apache.commons.lang3.mutable.MutableFloat;
+ +
+import java.util.OptionalDouble;
+
+public final class CombatUtil { +public final class CombatUtil {
+ private static final Reference2FloatMap<Item> LEGACY_ITEM_DAMAGE_MAP = new Reference2FloatOpenHashMap<>();
+
+ static {
+ LEGACY_ITEM_DAMAGE_MAP.defaultReturnValue(Float.MIN_VALUE);
+ for (Item item : BuiltInRegistries.ITEM) {
+ if (item instanceof TieredItem tieredItem) {
+ float weaponDamage = baseToolDamage(tieredItem) + tieredItem.getTier().getAttackDamageBonus();
+ LEGACY_ITEM_DAMAGE_MAP.put(item, weaponDamage);
+ }
+ if (item instanceof HoeItem) {
+ LEGACY_ITEM_DAMAGE_MAP.put(item, 0.0f);
+ }
+ }
+ }
+
+ private static float baseToolDamage(TieredItem item) {
+ return switch (item) {
+ case SwordItem swordItem -> 4.0f;
+ case AxeItem axeItem -> 3.0f;
+ case PickaxeItem pickaxeItem -> 2.0f;
+ case ShovelItem shovelItem -> 1.0f;
+ case null, default -> 0.0f;
+ };
+ }
+
+ public static double getLegacyAttackDifference(ItemStack itemstack) { + public static double getLegacyAttackDifference(ItemStack itemstack) {
+ ItemAttributeModifiers defaultModifiers = itemstack.getItem().components().get(DataComponents.ATTRIBUTE_MODIFIERS); + ItemAttributeModifiers defaultModifiers = itemstack.getItem().components().get(DataComponents.ATTRIBUTE_MODIFIERS);
+ if (defaultModifiers != null && !defaultModifiers.modifiers().isEmpty()) { // exists + if (defaultModifiers != null && !defaultModifiers.modifiers().isEmpty()) { // exists
@@ -73,9 +47,9 @@ index 0000000000000000000000000000000000000000..9c58f13396609ddd2bf7a909f2f20bd6
+ baseAttack += entry.modifier().amount(); + baseAttack += entry.modifier().amount();
+ } + }
+ +
+ float legacyAttack = LEGACY_ITEM_DAMAGE_MAP.getFloat(itemstack.getItem()); + OptionalDouble legacyAttack = LegacyDamageMapping.itemAttackDamage(itemstack.getItem());
+ if (baseAttack != 0.0f && legacyAttack != Float.MIN_VALUE) { + if (baseAttack != 0.0 && legacyAttack.isPresent()) {
+ return (double) legacyAttack - baseAttack; + return legacyAttack.getAsDouble() - baseAttack;
+ } + }
+ } + }
+ return 0; + return 0;
@@ -100,11 +74,81 @@ index 0000000000000000000000000000000000000000..9c58f13396609ddd2bf7a909f2f20bd6
+ return enchantments.getOrThrow(enchantmentKey); + return enchantments.getOrThrow(enchantmentKey);
+ } + }
+} +}
diff --git a/src/main/java/me/samsuik/sakura/player/combat/LegacyDamageMapping.java b/src/main/java/me/samsuik/sakura/player/combat/LegacyDamageMapping.java
new file mode 100644
index 0000000000000000000000000000000000000000..b4ab8f172d713204bb9c1ebf575dcc28bd7dd73e
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/player/combat/LegacyDamageMapping.java
@@ -0,0 +1,64 @@
+package me.samsuik.sakura.player.combat;
+
+import it.unimi.dsi.fastutil.objects.Reference2DoubleMap;
+import it.unimi.dsi.fastutil.objects.Reference2DoubleOpenHashMap;
+import net.minecraft.core.component.DataComponents;
+import net.minecraft.core.registries.BuiltInRegistries;
+import net.minecraft.world.entity.ai.attributes.Attributes;
+import net.minecraft.world.item.*;
+import net.minecraft.world.item.component.ItemAttributeModifiers;
+
+import java.util.OptionalDouble;
+
+public final class LegacyDamageMapping {
+ private static final Reference2DoubleMap<Item> LEGACY_ITEM_DAMAGE_MAP = new Reference2DoubleOpenHashMap<>();
+
+ public static OptionalDouble itemAttackDamage(Item item) {
+ double result = LEGACY_ITEM_DAMAGE_MAP.getDouble(item);
+ return result == Double.MIN_VALUE ? OptionalDouble.empty() : OptionalDouble.of(result);
+ }
+
+ private static double adjustDamageForItem(Item item, double attackDamage) {
+ return switch (item) {
+ case SwordItem i -> 1.0;
+ case PickaxeItem i -> 1.0;
+ case ShovelItem i -> -0.5;
+ case HoeItem i -> -attackDamage;
+ case null, default -> 0.0;
+ };
+ }
+
+ static {
+ LEGACY_ITEM_DAMAGE_MAP.defaultReturnValue(Double.MIN_VALUE);
+
+ // tool material is no longer exposed
+ LEGACY_ITEM_DAMAGE_MAP.put(Items.WOODEN_AXE, 3.0);
+ LEGACY_ITEM_DAMAGE_MAP.put(Items.GOLDEN_AXE, 3.0);
+ LEGACY_ITEM_DAMAGE_MAP.put(Items.STONE_AXE, 4.0);
+ LEGACY_ITEM_DAMAGE_MAP.put(Items.IRON_AXE, 5.0);
+ LEGACY_ITEM_DAMAGE_MAP.put(Items.DIAMOND_AXE, 6.0);
+ LEGACY_ITEM_DAMAGE_MAP.put(Items.NETHERITE_AXE, 7.0);
+
+ for (Item item : BuiltInRegistries.ITEM) {
+ ItemAttributeModifiers modifiers = item.components().get(DataComponents.ATTRIBUTE_MODIFIERS);
+
+ if (modifiers == null || LEGACY_ITEM_DAMAGE_MAP.containsKey(item)) {
+ continue;
+ }
+
+ assert item instanceof AxeItem : "missing axe mapping";
+
+ double attackDamage = modifiers.modifiers().stream()
+ .filter(e -> e.attribute().is(Attributes.ATTACK_DAMAGE))
+ .mapToDouble(e -> e.modifier().amount())
+ .sum();
+
+ if (attackDamage > 0.0) {
+ double adjustment = adjustDamageForItem(item, attackDamage);
+ LEGACY_ITEM_DAMAGE_MAP.put(item, attackDamage + adjustment);
+ }
+ }
+ }
+
+ private LegacyDamageMapping() {}
+}
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 35b75be4ace452e684439ef2f0a6fa6d83f8f6cc..34721b0555f3977f85d72d9e704bbe49654ee19d 100644 index c477eb3ea41e7d7caa04179248f116f617317cbd..3534821c8b600b9b3d3655c071fc59a3e3b4c23e 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -299,6 +299,43 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -310,6 +310,43 @@ public abstract class LivingEntity extends Entity implements Attackable {
++this.noActionTime; // Above all the floats ++this.noActionTime; // Above all the floats
} }
// Spigot end // Spigot end
@@ -129,7 +173,7 @@ index 35b75be4ace452e684439ef2f0a6fa6d83f8f6cc..34721b0555f3977f85d72d9e704bbe49
+ +
+ if (this.level().sakuraConfig().players.combat.legacyCombatMechanics) { + if (this.level().sakuraConfig().players.combat.legacyCombatMechanics) {
+ ItemStack heldItem = this.getLastHandItem(EquipmentSlot.MAINHAND); + ItemStack heldItem = this.getLastHandItem(EquipmentSlot.MAINHAND);
+ double attackDifference = me.samsuik.sakura.utils.CombatUtil.getLegacyAttackDifference(heldItem); + double attackDifference = me.samsuik.sakura.player.combat.CombatUtil.getLegacyAttackDifference(heldItem);
+ legacyModifier = new AttributeModifier(LEGACY_COMBAT_MODIFIER_ID, attackDifference, AttributeModifier.Operation.ADD_VALUE); + legacyModifier = new AttributeModifier(LEGACY_COMBAT_MODIFIER_ID, attackDifference, AttributeModifier.Operation.ADD_VALUE);
+ } + }
+ +
@@ -148,7 +192,7 @@ index 35b75be4ace452e684439ef2f0a6fa6d83f8f6cc..34721b0555f3977f85d72d9e704bbe49
protected LivingEntity(EntityType<? extends LivingEntity> type, Level world) { protected LivingEntity(EntityType<? extends LivingEntity> type, Level world) {
super(type, world); super(type, world);
@@ -2210,7 +2247,16 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -2285,7 +2322,16 @@ public abstract class LivingEntity extends Entity implements Attackable {
protected float getDamageAfterArmorAbsorb(DamageSource source, float amount) { protected float getDamageAfterArmorAbsorb(DamageSource source, float amount) {
if (!source.is(DamageTypeTags.BYPASSES_ARMOR)) { if (!source.is(DamageTypeTags.BYPASSES_ARMOR)) {
// this.hurtArmor(damagesource, f); // CraftBukkit - actuallyHurt(DamageSource, float, EntityDamageEvent) for handle damage // this.hurtArmor(damagesource, f); // CraftBukkit - actuallyHurt(DamageSource, float, EntityDamageEvent) for handle damage
@@ -165,31 +209,30 @@ index 35b75be4ace452e684439ef2f0a6fa6d83f8f6cc..34721b0555f3977f85d72d9e704bbe49
} }
return amount; return amount;
@@ -3352,6 +3398,12 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -3458,6 +3504,11 @@ public abstract class LivingEntity extends Entity implements Attackable {
}); EnchantmentHelper.runLocationChangedEffects(worldserver, itemstack, this, enumitemslot1);
}
+ // Sakura start - legacy combat mechanics
+ if (this instanceof ServerPlayer && enumitemslot1 == EquipmentSlot.MAINHAND) {
+ this.updateAttackSpeedModifier();
+ }
+ // Sakura end - legacy combat mechanics
} }
+
+ // Sakura start - legacy combat mechanics
+ if (this instanceof ServerPlayer && enumitemslot1 == EquipmentSlot.MAINHAND) {
+ this.updateAttackSpeedModifier();
+ }
+ // Sakura end - legacy combat mechanics
} }
} }
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java 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 5c3bebf932b6f0376711a2bd679062575bff04a3..5d16462e1fab47f0587449d0f6e94886831d6ff3 100644 index 16f6834b88bf0b2f2157e25240e6bc51db501dce..8c8cf4b640439ca10bc030fa3194f3ff61d10e6b 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java --- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -1278,14 +1278,20 @@ public abstract class Player extends LivingEntity { @@ -1240,14 +1240,20 @@ public abstract class Player extends LivingEntity {
if (playerAttackEntityEvent.callEvent() && willAttack) { // Logic moved to willAttack local variable. if (playerAttackEntityEvent.callEvent() && willAttack) { // Logic moved to willAttack local variable.
{ {
// Paper end - PlayerAttackEntityEvent // Paper end - PlayerAttackEntityEvent
- float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float) this.getAttributeValue(Attributes.ATTACK_DAMAGE); - float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float) this.getAttributeValue(Attributes.ATTACK_DAMAGE);
+ float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : this.getAttackDamageFromAttributes(); // Sakura - legacy combat mechanics + float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : this.getAttackDamageFromAttributes(); // Sakura - legacy combat mechanics
ItemStack itemstack = this.getWeaponItem(); ItemStack itemstack = this.getWeaponItem();
DamageSource damagesource = this.damageSources().playerAttack(this); DamageSource damagesource = (DamageSource) Optional.ofNullable(itemstack.getItem().getDamageSource(this)).orElse(this.damageSources().playerAttack(this));
float f1 = this.getEnchantedDamage(target, f, damagesource) - f; float f1 = this.getEnchantedDamage(target, f, damagesource) - f;
float f2 = this.getAttackStrengthScale(0.5F); float f2 = this.getAttackStrengthScale(0.5F);
@@ -198,13 +241,13 @@ index 5c3bebf932b6f0376711a2bd679062575bff04a3..5d16462e1fab47f0587449d0f6e94886
f *= 0.2F + f2 * f2 * 0.8F; f *= 0.2F + f2 * f2 * 0.8F;
f1 *= f2; f1 *= f2;
+ } else if (f1 != 0.0) { + } else if (f1 != 0.0) {
+ f1 += me.samsuik.sakura.utils.CombatUtil.calculateLegacySharpnessDamage(this, itemstack, damagesource); + f1 += me.samsuik.sakura.player.combat.CombatUtil.calculateLegacySharpnessDamage(this, itemstack, damagesource);
+ } + }
+ // Sakura end - legacy combat mechanics + // Sakura end - legacy combat mechanics
// this.resetAttackStrengthTicker(); // CraftBukkit - Moved to EntityLiving to reset the cooldown after the damage is dealt // this.resetAttackStrengthTicker(); // CraftBukkit - Moved to EntityLiving to reset the cooldown after the damage is dealt
if (target.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE) && target instanceof Projectile) { if (target.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE) && target instanceof Projectile) {
Projectile iprojectile = (Projectile) target; Projectile iprojectile = (Projectile) target;
@@ -1313,7 +1319,7 @@ public abstract class Player extends LivingEntity { @@ -1275,7 +1281,7 @@ public abstract class Player extends LivingEntity {
} }
f += itemstack.getItem().getAttackDamageBonus(target, f, damagesource); f += itemstack.getItem().getAttackDamageBonus(target, f, damagesource);

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Allow disabling sweep attacks
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java 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 d4485ecff16969e57241d3841efbe1745c0814aa..a5417a76897395129baaf0eea8ed0a0cd60d9335 100644 index 8c8cf4b640439ca10bc030fa3194f3ff61d10e6b..a99903df673f7cde190a880b681d44be0b747c90 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java --- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -1386,7 +1386,7 @@ public abstract class Player extends LivingEntity { @@ -1348,7 +1348,7 @@ public abstract class Player extends LivingEntity {
LivingEntity entityliving2; LivingEntity entityliving2;

View File

@@ -5,11 +5,11 @@ Subject: [PATCH] Change shields to reduce damage
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 34721b0555f3977f85d72d9e704bbe49654ee19d..5da12031d773ec9325bf7c592a1c3c854281da72 100644 index 3534821c8b600b9b3d3655c071fc59a3e3b4c23e..88dc63e5c739eb39822999d226856205a3c6099b 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -2341,7 +2341,13 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -2416,7 +2416,13 @@ public abstract class LivingEntity extends Entity implements Attackable {
Function<Double, Double> blocking = new Function<Double, Double>() { com.google.common.base.Function<Double, Double> blocking = new com.google.common.base.Function<Double, Double>() {
@Override @Override
public Double apply(Double f) { public Double apply(Double f) {
+ // Sakura start - shield damage reduction + // Sakura start - shield damage reduction

View File

@@ -0,0 +1,88 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
Date: Fri, 23 Feb 2024 14:40:32 +0000
Subject: [PATCH] Old enchanted golden apples
diff --git a/src/main/java/me/samsuik/sakura/player/combat/CustomGoldenApple.java b/src/main/java/me/samsuik/sakura/player/combat/CustomGoldenApple.java
new file mode 100644
index 0000000000000000000000000000000000000000..18cb28a9bdfcb9a421bc001f057b4be54c1550be
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/player/combat/CustomGoldenApple.java
@@ -0,0 +1,64 @@
+package me.samsuik.sakura.player.combat;
+
+import net.minecraft.core.component.DataComponents;
+import net.minecraft.world.InteractionHand;
+import net.minecraft.world.InteractionResult;
+import net.minecraft.world.effect.MobEffectInstance;
+import net.minecraft.world.effect.MobEffects;
+import net.minecraft.world.entity.LivingEntity;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.item.Item;
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.component.Consumable;
+import net.minecraft.world.item.component.Consumables;
+import net.minecraft.world.item.consume_effects.ApplyStatusEffectsConsumeEffect;
+import net.minecraft.world.level.Level;
+import org.jspecify.annotations.NullMarked;
+
+import java.util.List;
+import java.util.Optional;
+
+@NullMarked
+@SuppressWarnings("OptionalAssignedToNull")
+public final class CustomGoldenApple extends Item {
+ private static final Consumable LEGACY_ENCHANTED_GOLDEN_APPLE = Consumables.defaultFood()
+ .onConsume(
+ new ApplyStatusEffectsConsumeEffect(
+ List.of(
+ new MobEffectInstance(MobEffects.REGENERATION, 600, 4),
+ new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 6000, 0),
+ new MobEffectInstance(MobEffects.FIRE_RESISTANCE, 6000, 0),
+ new MobEffectInstance(MobEffects.ABSORPTION, 2400, 0)
+ )
+ )
+ )
+ .build();
+
+ public CustomGoldenApple(Properties settings) {
+ super(settings);
+ }
+
+ @Override
+ public InteractionResult use(Level level, Player player, InteractionHand hand) {
+ ItemStack stack = player.getItemInHand(hand);
+ if (this.itemHasConsumableComponent(stack, level)) {
+ return super.use(level, player, hand);
+ } else {
+ return LEGACY_ENCHANTED_GOLDEN_APPLE.startConsuming(player, stack, hand);
+ }
+ }
+
+ @Override
+ public ItemStack finishUsingItem(ItemStack stack, Level level, LivingEntity entity) {
+ if (this.itemHasConsumableComponent(stack, level)) {
+ return super.finishUsingItem(stack, level, entity);
+ } else {
+ return LEGACY_ENCHANTED_GOLDEN_APPLE.onConsume(level, entity, stack);
+ }
+ }
+
+ private boolean itemHasConsumableComponent(ItemStack stack, Level level) {
+ Optional<?> consumable = stack.getComponentsPatch().get(DataComponents.CONSUMABLE);
+ return consumable != null || !level.sakuraConfig().players.combat.oldEnchantedGoldenApple;
+ }
+}
diff --git a/src/main/java/net/minecraft/world/item/Items.java b/src/main/java/net/minecraft/world/item/Items.java
index 5a70111cd39af50981cfd440c021340da1de5eab..92a3ae94e936809004c9664c18dae74edf154399 100644
--- a/src/main/java/net/minecraft/world/item/Items.java
+++ b/src/main/java/net/minecraft/world/item/Items.java
@@ -1174,6 +1174,7 @@ public class Items {
public static final Item GOLDEN_APPLE = registerItem("golden_apple", new Item.Properties().food(Foods.GOLDEN_APPLE, Consumables.GOLDEN_APPLE));
public static final Item ENCHANTED_GOLDEN_APPLE = registerItem(
"enchanted_golden_apple",
+ me.samsuik.sakura.player.combat.CustomGoldenApple::new, // Sakura - old enchanted golden apples
new Item.Properties()
.rarity(Rarity.RARE)
.food(Foods.ENCHANTED_GOLDEN_APPLE, Consumables.ENCHANTED_GOLDEN_APPLE)

View File

@@ -5,12 +5,12 @@ Subject: [PATCH] Configure fast health regen
diff --git a/src/main/java/net/minecraft/world/food/FoodData.java b/src/main/java/net/minecraft/world/food/FoodData.java diff --git a/src/main/java/net/minecraft/world/food/FoodData.java b/src/main/java/net/minecraft/world/food/FoodData.java
index bd3f78e6453cfe18aa3da38176b04d734d83bb4b..22160241bd421d02f8ecec37899597c0c0afb53e 100644 index 6a686be6a69ae890d519a54ca099d4ba14e5b9e1..bb8dcd7e307c033806de392fecf41a235c7d7765 100644
--- a/src/main/java/net/minecraft/world/food/FoodData.java --- a/src/main/java/net/minecraft/world/food/FoodData.java
+++ b/src/main/java/net/minecraft/world/food/FoodData.java +++ b/src/main/java/net/minecraft/world/food/FoodData.java
@@ -83,7 +83,7 @@ public class FoodData { @@ -74,7 +74,7 @@ public class FoodData {
boolean flag = player.level().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION); boolean flag = worldserver.getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION);
- if (flag && this.saturationLevel > 0.0F && player.isHurt() && this.foodLevel >= 20) { - if (flag && this.saturationLevel > 0.0F && player.isHurt() && this.foodLevel >= 20) {
+ if (flag && this.saturationLevel > 0.0F && player.isHurt() && this.foodLevel >= 20 && player.level().sakuraConfig().players.combat.fastHealthRegen) { // Sakura - configure fast health regen + if (flag && this.saturationLevel > 0.0F && player.isHurt() && this.foodLevel >= 20 && player.level().sakuraConfig().players.combat.fastHealthRegen) { // Sakura - configure fast health regen

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Add option for fishing hooks pulling entities
diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
index 43a3ac5858ffb2007e6f63ec0f3bc5a9971dce14..bf8f903bb03b58c53c8307323f3f94779300b7e0 100644 index c563f71fb79990771d032b8044b8f676d8d21058..651a1d6313df92258d9af00ceb57142ebc40fee5 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java --- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java +++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
@@ -616,7 +616,7 @@ public class FishingHook extends Projectile { @@ -621,7 +621,7 @@ public class FishingHook extends Projectile {
public void pullEntity(Entity entity) { public void pullEntity(Entity entity) {
Entity entity1 = this.getOwner(); Entity entity1 = this.getOwner();

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Old combat sounds and particle effects
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java 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 a5417a76897395129baaf0eea8ed0a0cd60d9335..2c88d4956894e19e773f569679396d5c6058781b 100644 index a99903df673f7cde190a880b681d44be0b747c90..97e078989ccbb25d5a82c2dd7d034079ce4b9acf 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java --- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -1496,7 +1496,7 @@ public abstract class Player extends LivingEntity { @@ -1458,7 +1458,7 @@ public abstract class Player extends LivingEntity {
float f8 = f4 - ((LivingEntity) target).getHealth(); float f8 = f4 - ((LivingEntity) target).getHealth();
this.awardStat(Stats.DAMAGE_DEALT, Math.round(f8 * 10.0F)); this.awardStat(Stats.DAMAGE_DEALT, Math.round(f8 * 10.0F));
@@ -17,7 +17,7 @@ index a5417a76897395129baaf0eea8ed0a0cd60d9335..2c88d4956894e19e773f569679396d5c
int i = (int) ((double) f8 * 0.5D); int i = (int) ((double) f8 * 0.5D);
((ServerLevel) this.level()).sendParticles(ParticleTypes.DAMAGE_INDICATOR, target.getX(), target.getY(0.5D), target.getZ(), i, 0.1D, 0.0D, 0.1D, 0.2D); ((ServerLevel) this.level()).sendParticles(ParticleTypes.DAMAGE_INDICATOR, target.getX(), target.getY(0.5D), target.getZ(), i, 0.1D, 0.0D, 0.1D, 0.2D);
@@ -1915,6 +1915,7 @@ public abstract class Player extends LivingEntity { @@ -1866,6 +1866,7 @@ public abstract class Player extends LivingEntity {
} }
// Paper start - send while respecting visibility // Paper start - send while respecting visibility
private static void sendSoundEffect(Player fromEntity, double x, double y, double z, SoundEvent soundEffect, SoundSource soundCategory, float volume, float pitch) { private static void sendSoundEffect(Player fromEntity, double x, double y, double z, SoundEvent soundEffect, SoundSource soundCategory, float volume, float pitch) {

View File

@@ -1,42 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
Date: Fri, 23 Feb 2024 14:40:32 +0000
Subject: [PATCH] Old enchanted golden apples
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 5da12031d773ec9325bf7c592a1c3c854281da72..4562a9c7327c6981e36cbeda88b53b44f1bbf20b 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -4538,6 +4538,11 @@ public abstract class LivingEntity extends Entity implements Attackable {
public final ItemStack eat(Level world, ItemStack stack) {
FoodProperties foodinfo = (FoodProperties) stack.get(DataComponents.FOOD);
+ // Sakura start - old enchanted golden apple
+ if (this.level().sakuraConfig().players.combat.oldEnchantedGoldenApple && foodinfo == net.minecraft.world.food.Foods.ENCHANTED_GOLDEN_APPLE) {
+ foodinfo = net.minecraft.world.food.Foods.LEGACY_ENCHANTED_GOLDEN_APPLE;
+ }
+ // Sakura end - old enchanted golden apple
return foodinfo != null ? this.eat(world, stack, foodinfo) : stack;
}
diff --git a/src/main/java/net/minecraft/world/food/Foods.java b/src/main/java/net/minecraft/world/food/Foods.java
index e13d9ed48431b019b1f68aae315af74cec34fcee..c2e113016b233377f6e8b032336707a4c1b001f5 100644
--- a/src/main/java/net/minecraft/world/food/Foods.java
+++ b/src/main/java/net/minecraft/world/food/Foods.java
@@ -37,6 +37,15 @@ public class Foods {
.effect(new MobEffectInstance(MobEffects.ABSORPTION, 2400, 3), 1.0F)
.alwaysEdible()
.build();
+ public static final FoodProperties LEGACY_ENCHANTED_GOLDEN_APPLE = new FoodProperties.Builder()
+ .nutrition(4)
+ .saturationModifier(1.2F)
+ .effect(new MobEffectInstance(MobEffects.REGENERATION, 600, 4), 1.0F)
+ .effect(new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 6000, 0), 1.0F)
+ .effect(new MobEffectInstance(MobEffects.FIRE_RESISTANCE, 6000, 0), 1.0F)
+ .effect(new MobEffectInstance(MobEffects.ABSORPTION, 2400, 0), 1.0F)
+ .alwaysEdible()
+ .build();
public static final FoodProperties GOLDEN_APPLE = new FoodProperties.Builder()
.nutrition(4)
.saturationModifier(1.2F)

View File

@@ -4,11 +4,11 @@ Date: Mon, 17 Jun 2024 14:04:12 +0100
Subject: [PATCH] Protect scaffolding from creepers Subject: [PATCH] Protect scaffolding from creepers
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java
index 98df890c88c6635566b5702080753f5cb0c20598..d7278a4f2a186532a9b4a57af8dad47b86660068 100644 index ace34cc86061bb4c9b080c6e9bf912b1fe3533a6..280308766cd41924e209d5816c047ceae0ec1085 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java --- a/src/main/java/net/minecraft/world/level/ServerExplosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java
@@ -180,6 +180,11 @@ public class Explosion { @@ -412,6 +412,11 @@ public class ServerExplosion implements Explosion {
return Optional.of(ZERO_RESISTANCE); return Optional.of(ZERO_RESISTANCE);
} }
// Sakura end - allow explosions to destroy lava // Sakura end - allow explosions to destroy lava
@@ -19,4 +19,4 @@ index 98df890c88c6635566b5702080753f5cb0c20598..d7278a4f2a186532a9b4a57af8dad47b
+ // Sakura end - protect scaffolding from creepers + // Sakura end - protect scaffolding from creepers
} }
return this.damageCalculator.getBlockExplosionResistance((Explosion)(Object)this, this.level, pos, blockState, fluidState); return this.damageCalculator.getBlockExplosionResistance(this, this.level, pos, blockState, fluidState);

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Entity tracking range modifier
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 47e1bec18c9bed6028b63ed6a1bcc66bcd4df238..80c5515b481c01e3a2fb59d4a69bc0a0d2b01792 100644 index 44e897e9a4bcb75858e1d32b1095b2d4b70f2463..d7d29b0e8c4dbc4db52dd52a2e5572f1f4d052f9 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1290,7 +1290,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1327,7 +1327,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
double vec3d_dz = player.getZ() - this.entity.getZ(); double vec3d_dz = player.getZ() - this.entity.getZ();
// Paper end - remove allocation of Vec3D here // Paper end - remove allocation of Vec3D here
int i = ChunkMap.this.getPlayerViewDistance(player); int i = ChunkMap.this.getPlayerViewDistance(player);
@@ -21,10 +21,10 @@ index 47e1bec18c9bed6028b63ed6a1bcc66bcd4df238..80c5515b481c01e3a2fb59d4a69bc0a0
double d2 = d0 * d0; double d2 = d0 * d0;
// Paper start - Configurable entity tracking range by Y // Paper start - Configurable entity tracking range by Y
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 007bc568d3fb23f08790044aa3171727996927dc..4a5844be3683f502eebe01eed7ff1c2a6bf99962 100644 index ad85e5ebe00918a7fea4071351741566e4883dd0..58202fab518f8072ad8dc8d10aa2a9f6b406a327 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -333,6 +333,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple @@ -360,6 +360,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
return this.viewDistanceHolder; return this.viewDistanceHolder;
} }
// Paper end - rewrite chunk system // Paper end - rewrite chunk system
@@ -33,10 +33,10 @@ index 007bc568d3fb23f08790044aa3171727996927dc..4a5844be3683f502eebe01eed7ff1c2a
public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, ClientInformation clientOptions) { public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, ClientInformation clientOptions) {
super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile); super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 71f9c53cb3a3130adcbbf92a081fbe2b32efd626..581a9efe67f3b803688679609d1feb0b601c9bde 100644 index 20c271879a79cc23c57421782e1199e0d52dfc2f..c946be760aa6c0503ca0727b7b372701f3586c9b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -3022,6 +3022,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -3046,6 +3046,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
return (this.getHandle().requestedViewDistance() == 0) ? Bukkit.getViewDistance() : this.getHandle().requestedViewDistance(); return (this.getHandle().requestedViewDistance() == 0) ? Bukkit.getViewDistance() : this.getHandle().requestedViewDistance();
} }

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Set entity impulse on explosion
diff --git a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java diff --git a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java
index 8db362721860fe8d5eb497a766e6d1b7879cb455..911d1d8bef53b549f5f77ca1ed1e5b2e5102ba54 100644 index 2ac8bd2cc879c493d9a008f7555c7277977129f5..8f5e17d6c132aedcd49e92bd0c82c9c6a4435282 100644
--- a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java --- a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java
+++ b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java +++ b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java
@@ -223,6 +223,7 @@ public abstract class SpecialisedExplosion<T extends Entity> extends Explosion { @@ -207,6 +207,7 @@ public abstract class SpecialisedExplosion<T extends Entity> extends ServerExplo
moveZ += z; moveZ += z;
} }
@@ -16,15 +16,15 @@ index 8db362721860fe8d5eb497a766e6d1b7879cb455..911d1d8bef53b549f5f77ca1ed1e5b2e
entity.setDeltaMovement(moveX, moveY, moveZ); entity.setDeltaMovement(moveX, moveY, moveZ);
} }
} }
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java
index d7278a4f2a186532a9b4a57af8dad47b86660068..60267afc1d0ca0ed2daeff27c804e544f7704700 100644 index 280308766cd41924e209d5816c047ceae0ec1085..2bc39d43c161dcbc2a8ff88fff7409d0c41fd588 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java --- a/src/main/java/net/minecraft/world/level/ServerExplosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java
@@ -786,6 +786,7 @@ public class Explosion { @@ -748,6 +748,7 @@ public class ServerExplosion implements Explosion {
// Paper end - knockback events // Paper end - knockback events
} }
// CraftBukkit end // CraftBukkit end
+ entity.hasImpulse = true; // Sakura - set entity impulse on explosion + entity.hasImpulse = true; // Sakura - set entity impulse on explosion
entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d1)); entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d));
if (entity instanceof Player) { if (entity instanceof Player) {
Player entityhuman = (Player) entity; Player entityhuman = (Player) entity;

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Configurable left shooting and adjusting limits
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 11c91e62ad71fbe8b22e417c6d942c8d0849a863..2201bd3639482ec0e6f01b4f991bb4abfb5b9da6 100644 index 17255cc9739392d23b5b55f2be5660fc56d538d5..080b3dbeeee46eb4cbfa4af8b9c6bc1f85a22dda 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -632,6 +632,46 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -693,6 +693,46 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return Math.max(x, z) >= this.travelDistanceLimit; return Math.max(x, z) >= this.travelDistanceLimit;
} }
// Sakura end - entity travel distance limits // Sakura end - entity travel distance limits
@@ -55,7 +55,7 @@ index 11c91e62ad71fbe8b22e417c6d942c8d0849a863..2201bd3639482ec0e6f01b4f991bb4ab
public Entity(EntityType<?> type, Level world) { public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet(); this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -1687,6 +1727,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1764,6 +1804,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
} }
if (xSmaller && z != 0.0) { if (xSmaller && z != 0.0) {
@@ -63,7 +63,7 @@ index 11c91e62ad71fbe8b22e417c6d942c8d0849a863..2201bd3639482ec0e6f01b4f991bb4ab
z = this.scanZ(currBoundingBox, z, voxelList, bbList); z = this.scanZ(currBoundingBox, z, voxelList, bbList);
if (z != 0.0) { if (z != 0.0) {
currBoundingBox = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.offsetZ(currBoundingBox, z); currBoundingBox = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.offsetZ(currBoundingBox, z);
@@ -1694,6 +1735,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1771,6 +1812,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
} }
if (x != 0.0) { if (x != 0.0) {
@@ -76,14 +76,14 @@ index 11c91e62ad71fbe8b22e417c6d942c8d0849a863..2201bd3639482ec0e6f01b4f991bb4ab
if (x != 0.0) { if (x != 0.0) {
currBoundingBox = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.offsetX(currBoundingBox, x); currBoundingBox = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.offsetX(currBoundingBox, x);
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java 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 87a5e151895c7fac32afc3b44088e5e75856dcd7..d722542fd1295669208946daa839c12cdf6886a9 100644 index 2d9e42465d4a8adf2095d3d23b29df29af3df00d..20c67c47d90b5a41d6db783fda460636873638c4 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -261,6 +261,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti @@ -270,6 +270,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
// Sakura end - physics version api // Sakura end - physics version api
++this.time; ++this.time;
this.applyGravity(); this.applyGravity();
+ this.limitLeftShooting(); // Sakura - configurable left shooting and adjusting limits + this.limitLeftShooting(); // Sakura - configurable left shooting and adjusting limits
this.moveStripped(MoverType.SELF, this.getDeltaMovement()); // Sakura - optimise cannon entity movement this.moveStripped(MoverType.SELF, this.getDeltaMovement()); // Sakura - optimise cannon entity movement
this.applyEffectsFromBlocks();
// Paper start - Configurable falling blocks height nerf // Paper start - Configurable falling blocks height nerf
if (this.level().paperConfig().fixes.fallingBlockHeightNerf.test(v -> this.getY() > v)) {

View File

@@ -42,10 +42,10 @@ index 5db5ba026462ca642dcee718af732f80fadabef5..51e26395b53628b34b1f7f68935a9ba4
boolean isEmpty(); boolean isEmpty();
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 062bc318e9c4e3b9a6429ce0eaaa29081cd1d227..11e89d518d45b42bb39689e6ac1635b54ec8e41f 100644 index 8c41282eafc1201bf1c0d001fb4fe791f3173f87..4361a08c3f60980c86f5b7953d6171016ad7166b 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -1579,7 +1579,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -1648,7 +1648,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
tilesThisCycle--; tilesThisCycle--;
toRemove.add(tickingblockentity); // Paper - Fix MC-117075; use removeAll toRemove.add(tickingblockentity); // Paper - Fix MC-117075; use removeAll
// Spigot end // Spigot end
@@ -55,10 +55,10 @@ index 062bc318e9c4e3b9a6429ce0eaaa29081cd1d227..11e89d518d45b42bb39689e6ac1635b5
// Paper start - rewrite chunk system // Paper start - rewrite chunk system
if ((++tickedEntities & 7) == 0) { if ((++tickedEntities & 7) == 0) {
diff --git a/src/main/java/net/minecraft/world/level/block/HopperBlock.java b/src/main/java/net/minecraft/world/level/block/HopperBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/HopperBlock.java b/src/main/java/net/minecraft/world/level/block/HopperBlock.java
index 3e1c7d62c24dd48a805260d156135dc4f0c3d1fc..ced5fb075349a9b944708aeaabe82b3350ac5d4d 100644 index 005a2a66a6e8a492acfa7ba91117884cda08562d..00a2eeeedaadb9e7486e6b366bef6c15e48d23cd 100644
--- a/src/main/java/net/minecraft/world/level/block/HopperBlock.java --- a/src/main/java/net/minecraft/world/level/block/HopperBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/HopperBlock.java +++ b/src/main/java/net/minecraft/world/level/block/HopperBlock.java
@@ -144,6 +144,12 @@ public class HopperBlock extends BaseEntityBlock { @@ -140,6 +140,12 @@ public class HopperBlock extends BaseEntityBlock {
private void checkPoweredState(Level world, BlockPos pos, BlockState state) { private void checkPoweredState(Level world, BlockPos pos, BlockState state) {
boolean bl = !world.hasNeighborSignal(pos); boolean bl = !world.hasNeighborSignal(pos);
if (bl != state.getValue(ENABLED)) { if (bl != state.getValue(ENABLED)) {
@@ -72,10 +72,10 @@ index 3e1c7d62c24dd48a805260d156135dc4f0c3d1fc..ced5fb075349a9b944708aeaabe82b33
} }
} }
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
index 7dfabb11d3c8112f6daef35d204a2e324f4ddb5e..ffd464bd9dccb5f56b123833de4c255a0f11c0a0 100644 index 1f929b467a0ece3143af58a657cf5983c07a8d51..dafdaf4d34af9c0a3d7915957c9de243d03b06f7 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
@@ -54,6 +54,55 @@ public abstract class BlockEntity { @@ -49,6 +49,55 @@ public abstract class BlockEntity {
private BlockState blockState; private BlockState blockState;
private DataComponentMap components; private DataComponentMap components;
@@ -131,7 +131,7 @@ index 7dfabb11d3c8112f6daef35d204a2e324f4ddb5e..ffd464bd9dccb5f56b123833de4c255a
public BlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) { public BlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
this.components = DataComponentMap.EMPTY; this.components = DataComponentMap.EMPTY;
this.type = type; this.type = type;
@@ -231,12 +280,23 @@ public abstract class BlockEntity { @@ -227,12 +276,23 @@ public abstract class BlockEntity {
public void setChanged() { public void setChanged() {
if (this.level != null) { if (this.level != null) {
if (ignoreTileUpdates) return; // Paper - Perf: Optimize Hoppers if (ignoreTileUpdates) return; // Paper - Perf: Optimize Hoppers
@@ -156,7 +156,7 @@ index 7dfabb11d3c8112f6daef35d204a2e324f4ddb5e..ffd464bd9dccb5f56b123833de4c255a
world.blockEntityChanged(pos); world.blockEntityChanged(pos);
if (!state.isAir()) { if (!state.isAir()) {
world.updateNeighbourForOutputSignal(pos, state.getBlock()); world.updateNeighbourForOutputSignal(pos, state.getBlock());
@@ -267,6 +327,7 @@ public abstract class BlockEntity { @@ -263,6 +323,7 @@ public abstract class BlockEntity {
public void setRemoved() { public void setRemoved() {
this.remove = true; this.remove = true;
@@ -165,7 +165,7 @@ index 7dfabb11d3c8112f6daef35d204a2e324f4ddb5e..ffd464bd9dccb5f56b123833de4c255a
public void clearRemoved() { public void clearRemoved() {
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
index cab403efd471bb61835224eea4e99570d34dcaaa..a359b592fb723e839e0a5ae9690da4e040abb13a 100644 index 5ebbdb94d9b91c442ff60eb6872f740ebd790fa0..ab82d62cc119cbeb981fcccded3dca8fc36eea66 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
@@ -42,7 +42,7 @@ import org.bukkit.event.inventory.InventoryPickupItemEvent; @@ -42,7 +42,7 @@ import org.bukkit.event.inventory.InventoryPickupItemEvent;
@@ -283,10 +283,10 @@ index 28e3b73507b988f7234cbf29c4024c88180d0aef..a0d247aa883553708c4b921582324255
+ // Sakura end - optimise hopper ticking + // Sakura end - optimise hopper ticking
} }
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java 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 7c11853c5090fbc4fa5b3e73a69acf166158fdec..debd755263d92198b3bafb02cf5eb78f01f0cec1 100644 index 4640baec5bed6c2d53cc0f8ca1d273cc115abe9b..aec495138c9724590be9bd5775189f0643b12a09 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -1000,6 +1000,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p @@ -1035,6 +1035,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
return this.ticker.getType(); return this.ticker.getType();
} }
@@ -300,7 +300,7 @@ index 7c11853c5090fbc4fa5b3e73a69acf166158fdec..debd755263d92198b3bafb02cf5eb78f
public String toString() { public String toString() {
return String.valueOf(this.ticker) + " <wrapped>"; return String.valueOf(this.ticker) + " <wrapped>";
} }
@@ -1076,6 +1083,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p @@ -1107,6 +1114,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
return BlockEntityType.getKey(this.blockEntity.getType()).toString(); return BlockEntityType.getKey(this.blockEntity.getType()).toString();
} }

View File

@@ -5,13 +5,13 @@ Subject: [PATCH] Tick entity schedulers only when necessary
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java
index dacf2b2988ce603879fe525a3418ac77f8a663f7..ed58e7f06a08bf5b56ea8fd68a7682f2fe203ccc 100644 index 58d9187adc188b693b6becc400f766e069bf1bf5..8b7860390717c3d2a3c0f3d2b081799bcd3d65c1 100644
--- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java --- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java
@@ -18,6 +18,22 @@ public final class ServerEntityLookup extends EntityLookup { @@ -19,6 +19,22 @@ public final class ServerEntityLookup extends EntityLookup {
private final ServerLevel serverWorld; private final ServerLevel serverWorld;
public final ReferenceList<Entity> trackerEntities = new ReferenceList<>(EMPTY_ENTITY_ARRAY); // Moonrise - entity tracker public final ReferenceList<Entity> trackerEntities = new ReferenceList<>(EMPTY_ENTITY_ARRAY); // Moonrise - entity tracker
public final ReferenceList<Entity> trackerUnloadedEntities = new ReferenceList<>(EMPTY_ENTITY_ARRAY); // Moonrise - entity tracker
+ // Sakura start - tick entity schedulers only when necessary + // Sakura start - tick entity schedulers only when necessary
+ public final ReferenceList<org.bukkit.craftbukkit.entity.CraftEntity> scheduledEntities = new ReferenceList<>(); + public final ReferenceList<org.bukkit.craftbukkit.entity.CraftEntity> scheduledEntities = new ReferenceList<>();
+ +
@@ -31,17 +31,17 @@ index dacf2b2988ce603879fe525a3418ac77f8a663f7..ed58e7f06a08bf5b56ea8fd68a7682f2
public ServerEntityLookup(final ServerLevel world, final LevelCallback<Entity> worldCallback) { public ServerEntityLookup(final ServerLevel world, final LevelCallback<Entity> worldCallback) {
super(world, worldCallback); super(world, worldCallback);
@@ -86,6 +102,7 @@ public final class ServerEntityLookup extends EntityLookup { @@ -90,6 +106,7 @@ public final class ServerEntityLookup extends EntityLookup {
// Moonrise start - entity tracker
this.trackerEntities.add(entity); this.trackerEntities.add(entity);
this.trackerUnloadedEntities.remove(entity);
// Moonrise end - entity tracker // Moonrise end - entity tracker
+ this.entityStartScheduled(entity); // Sakura - tick entity schedulers only when necessary + this.entityStartScheduled(entity); // Sakura - tick entity schedulers only when necessary
} }
@Override @Override
@@ -94,6 +111,7 @@ public final class ServerEntityLookup extends EntityLookup { @@ -97,6 +114,7 @@ public final class ServerEntityLookup extends EntityLookup {
// Moonrise start - entity tracker
this.trackerEntities.remove(entity); this.trackerEntities.remove(entity);
this.trackerUnloadedEntities.add(entity);
// Moonrise end - entity tracker // Moonrise end - entity tracker
+ this.entityEndScheduled(entity); // Sakura - tick entity schedulers only when necessary + this.entityEndScheduled(entity); // Sakura - tick entity schedulers only when necessary
} }
@@ -83,14 +83,14 @@ index c03608fec96b51e1867f43d8f42e5aefb1520e46..32ac34e6ca4a7443e894369fee349911
return true; return true;
} }
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 7073914cfd5759bea92ce098ad36a86afee5dd37..af59f640ce1f357b704cf0ce299af56b7253689c 100644 index 31dd38d80c648e3f946c123878529b3393be5a91..659a5bb2f73b27c6b0d733f0d563849c5c738550 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1734,7 +1734,17 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1811,7 +1811,17 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
// Paper start - Folia scheduler API // Paper start - Folia scheduler API
((io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler) Bukkit.getGlobalRegionScheduler()).tick(); ((io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler) Bukkit.getGlobalRegionScheduler()).tick();
getAllLevels().forEach(level -> { getAllLevels().forEach(level -> {
- for (final Entity entity : level.moonrise$getEntityLookup().getAllCopy()) { // Paper - rewrite chunk system - for (final Entity entity : level.getEntities().getAll()) {
+ // Sakura start - tick entity schedulers only when necessary + // Sakura start - tick entity schedulers only when necessary
+ final ca.spottedleaf.moonrise.patches.chunk_system.level.entity.server.ServerEntityLookup entityLookup = (ca.spottedleaf.moonrise.patches.chunk_system.level.entity.server.ServerEntityLookup) level.moonrise$getEntityLookup(); + final ca.spottedleaf.moonrise.patches.chunk_system.level.entity.server.ServerEntityLookup entityLookup = (ca.spottedleaf.moonrise.patches.chunk_system.level.entity.server.ServerEntityLookup) level.moonrise$getEntityLookup();
+ final Iterator<org.bukkit.craftbukkit.entity.CraftEntity> entityIterator = entityLookup.scheduledEntities.iterator(); + final Iterator<org.bukkit.craftbukkit.entity.CraftEntity> entityIterator = entityLookup.scheduledEntities.iterator();

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Add max armour durability damage
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 4562a9c7327c6981e36cbeda88b53b44f1bbf20b..222558ec09ed64574fcbcbd40537981cd2e6403d 100644 index 88dc63e5c739eb39822999d226856205a3c6099b..26f3a8a0e0ab07908f1130b404d792e5e0d21aae 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -2437,6 +2437,12 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -2512,6 +2512,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
// Apply damage to armor // Apply damage to armor
if (!damagesource.is(DamageTypeTags.BYPASSES_ARMOR)) { if (!damagesource.is(DamageTypeTags.BYPASSES_ARMOR)) {
float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT)); float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT));

View File

@@ -6,7 +6,7 @@ Subject: [PATCH] Modify bucket stack size
When a player interacts with a bucket this patch adds a data component to change the max stack size. When a player interacts with a bucket this patch adds a data component to change the max stack size.
diff --git a/src/main/java/net/minecraft/world/item/BucketItem.java b/src/main/java/net/minecraft/world/item/BucketItem.java diff --git a/src/main/java/net/minecraft/world/item/BucketItem.java b/src/main/java/net/minecraft/world/item/BucketItem.java
index 229d71f093f672f323cc2feadf2cd174a62805f8..ff41a87ae29bfa866cb7810d5d50f632a2e7412e 100644 index 4cb809976b42af933401e8fc34ee43e181761558..ed417a2f5a2105a25d1c2bd57e37785595738144 100644
--- a/src/main/java/net/minecraft/world/item/BucketItem.java --- a/src/main/java/net/minecraft/world/item/BucketItem.java
+++ b/src/main/java/net/minecraft/world/item/BucketItem.java +++ b/src/main/java/net/minecraft/world/item/BucketItem.java
@@ -49,6 +49,17 @@ public class BucketItem extends Item implements DispensibleContainerItem { @@ -49,6 +49,17 @@ public class BucketItem extends Item implements DispensibleContainerItem {
@@ -25,5 +25,5 @@ index 229d71f093f672f323cc2feadf2cd174a62805f8..ff41a87ae29bfa866cb7810d5d50f632
+ // Sakura end - modify bucket stack size + // Sakura end - modify bucket stack size
+ +
@Override @Override
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) { public InteractionResult use(Level world, Player user, InteractionHand hand) {
ItemStack itemstack = user.getItemInHand(hand); ItemStack itemstack = user.getItemInHand(hand);