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

Update feaure patches

This commit is contained in:
Samsuik
2025-04-07 01:37:23 +01:00
parent 0ecadc00f6
commit 4652ed3898
58 changed files with 693 additions and 666 deletions

View File

@@ -2,7 +2,7 @@ group=me.samsuik.sakura
version=1.21.5-R0.1-SNAPSHOT
mcVersion=1.21.5
paperRef=ce91a8ca123f4e853629d08705e4ece3a09a5a4d
paperRef=42623c4b27f579d874cab29bed7477608135c018
org.gradle.jvmargs=-Xmx2G
org.gradle.vfs.watch=false

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Client Visibility Settings API
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index c9fd51cc77d1155d3fe779f28618073287cdb488..c96b0d49556da54c9682c4cee576fd1be391530a 100644
index aeb6fe2329b06082c465cc9df10713a70243aeef..ccda08ea0f86164af26021432a622c88ff6a8183 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -69,6 +69,14 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Merge Cannon Entities API
diff --git a/src/main/java/org/bukkit/entity/FallingBlock.java b/src/main/java/org/bukkit/entity/FallingBlock.java
index 0f7d64c1c0221ef7fa933df8c5572dbfdcba5128..78d62651760ff0c9ebc5c01d2417c8c86e116df5 100644
index 3a7883629eb5bff5eef94389590d579a79a8e5d3..748dace28d791e6be6c5da8e21463d3b47cbeff5 100644
--- a/src/main/java/org/bukkit/entity/FallingBlock.java
+++ b/src/main/java/org/bukkit/entity/FallingBlock.java
@@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
@@ -18,7 +18,7 @@ index 0f7d64c1c0221ef7fa933df8c5572dbfdcba5128..78d62651760ff0c9ebc5c01d2417c8c8
// Sakura start - falling block height parity api
/**
diff --git a/src/main/java/org/bukkit/entity/TNTPrimed.java b/src/main/java/org/bukkit/entity/TNTPrimed.java
index 87e717c9ea61b0cbf536bc62fa829ddcfae5ad8c..2e89ea4e896bdea552ec40fca927920f5f96fd59 100644
index d97674b5f9269b0a952af7ba3ac86c8c92f1b81c..7a2de90d3340d6bfbaac545e7108a26340b5b753 100644
--- a/src/main/java/org/bukkit/entity/TNTPrimed.java
+++ b/src/main/java/org/bukkit/entity/TNTPrimed.java
@@ -6,7 +6,7 @@ import org.jetbrains.annotations.Nullable;

View File

@@ -1,8 +1,8 @@
--- a/src/main/java/org/bukkit/entity/Entity.java
+++ b/src/main/java/org/bukkit/entity/Entity.java
@@ -36,6 +_,22 @@
@@ -37,6 +_,22 @@
*/
public interface Entity extends Metadatable, CommandSender, Nameable, PersistentDataHolder, net.kyori.adventure.text.event.HoverEventSource<net.kyori.adventure.text.event.HoverEvent.ShowEntity>, net.kyori.adventure.sound.Sound.Emitter { // Paper
public interface Entity extends Metadatable, CommandSender, Nameable, PersistentDataHolder, net.kyori.adventure.text.event.HoverEventSource<net.kyori.adventure.text.event.HoverEvent.ShowEntity>, net.kyori.adventure.sound.Sound.Emitter, DataComponentView { // Paper
+ // Sakura start - entity pushed by fluid api
+ /**

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Track block changes and level tick scheduler
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index 3a926d4d34a7c68a24b9e00bcbcff271c8992ad2..259c2b2d459d86cb11ab848c77f48c38ed174a63 100644
index 40c906959d2708bf3e589f8e8d541d47106a8465..b234215e59ac303ef7979031ab1b042ff6692b7a 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -1749,6 +1749,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1747,6 +1747,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
profilerFiller.pop();
profilerFiller.pop();
serverLevel.explosionDensityCache.clear(); // Paper - Optimize explosions
@@ -17,10 +17,10 @@ index 3a926d4d34a7c68a24b9e00bcbcff271c8992ad2..259c2b2d459d86cb11ab848c77f48c38
this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 316dca7b4b20c6d05bf76f64a79984d10807dab5..9fbce0f31a73928a7db752e085fb3d0020fc6387 100644
index 787d7a76af7dfcaaa4b329df2cbe7cfcaa83d572..8aea98378fccb14f3eadab72a38e5661806b96c0 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -837,6 +837,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -824,6 +824,10 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
return chunk != null ? chunk.getNoiseBiome(x, y, z) : this.getUncachedNoiseBiome(x, y, z);
}
// Paper end - optimise random ticking
@@ -32,10 +32,10 @@ index 316dca7b4b20c6d05bf76f64a79984d10807dab5..9fbce0f31a73928a7db752e085fb3d00
protected Level(
WritableLevelData levelData,
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
index 761fdcd4a4e18f45547afd8edff44f61c6eeacb4..f8b5c74403ebf936bbac20d68a2dfa7b0aca9cfc 100644
index 5d3fc807221392d378fec283bfdefb8747fb8376..cfc125d43cf3702d46c221f4e7b0d66a15c5d690 100644
--- a/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
@@ -126,6 +126,21 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
@@ -127,6 +127,21 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
return this.getBlockStateFinal(x, y, z);
}
// Paper end - get block chunk optimisation
@@ -57,7 +57,7 @@ index 761fdcd4a4e18f45547afd8edff44f61c6eeacb4..f8b5c74403ebf936bbac20d68a2dfa7b
public LevelChunk(Level level, ChunkPos pos) {
this(level, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, null, null, null);
@@ -163,6 +178,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
@@ -164,6 +179,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
this.debug = !empty && this.level.isDebug();
this.defaultBlockState = empty ? VOID_AIR_BLOCKSTATE : AIR_BLOCKSTATE;
// Paper end - get block chunk optimisation
@@ -65,7 +65,7 @@ index 761fdcd4a4e18f45547afd8edff44f61c6eeacb4..f8b5c74403ebf936bbac20d68a2dfa7b
}
public LevelChunk(ServerLevel level, ProtoChunk chunk, @Nullable LevelChunk.PostLoadProcessor postLoad) {
@@ -404,6 +420,11 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
@@ -412,6 +428,11 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
if (!section.getBlockState(i, i1, i2).is(block)) {
return null;
} else {
@@ -74,6 +74,6 @@ index 761fdcd4a4e18f45547afd8edff44f61c6eeacb4..f8b5c74403ebf936bbac20d68a2dfa7b
+ this.blockChange(pos, state, blockState);
+ }
+ // Sakura end - track block changes and tick scheduler
if (!this.level.isClientSide && doPlace && (!this.level.captureBlockStates || block instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled.
state.onPlace(this.level, pos, blockState, isMoving);
if (!this.level.isClientSide && (flags & 512) == 0 && (!this.level.captureBlockStates || block instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled.
state.onPlace(this.level, pos, blockState, flag1);
}

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Client Visibility Settings
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
index 8f9f759885a9cda57ae7d665ec309a57e12969fd..e096463443639e9eef5311d7154f6d2ac1517883 100644
index dff3cc7456fe69ebd735aa950f79ce0dfed7e25e..07d8bb89ed0f9cea6353905939ba9f91c6fb64a5 100644
--- a/net/minecraft/server/level/ChunkMap.java
+++ b/net/minecraft/server/level/ChunkMap.java
@@ -168,6 +168,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -173,6 +173,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.handleLegacyStructureIndex(pos);
}
// Paper end - rewrite chunk system
@@ -16,9 +16,9 @@ index 8f9f759885a9cda57ae7d665ec309a57e12969fd..e096463443639e9eef5311d7154f6d2a
public ChunkMap(
ServerLevel level,
@@ -230,6 +231,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -237,6 +238,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
);
this.setServerViewDistance(viewDistance);
this.setServerViewDistance(serverViewDistance);
this.worldGenContext = new WorldGenContext(level, generator, structureManager, this.lightEngine, null, this::setChunkUnsaved); // Paper - rewrite chunk system
+ // Sakura start - client visibility settings; minimal tnt/sand
+ this.minimalEntities = new it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap();
@@ -27,7 +27,7 @@ index 8f9f759885a9cda57ae7d665ec309a57e12969fd..e096463443639e9eef5311d7154f6d2a
}
private void setChunkUnsaved(ChunkPos chunkPos) {
@@ -954,6 +959,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1016,6 +1021,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
tracker.serverEntity.sendChanges();
}
}
@@ -36,7 +36,7 @@ index 8f9f759885a9cda57ae7d665ec309a57e12969fd..e096463443639e9eef5311d7154f6d2a
}
// Paper end - optimise entity tracker
@@ -1164,6 +1171,32 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1226,6 +1233,32 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return !this.seenBy.isEmpty();
}
// Paper end - optimise entity tracker
@@ -68,8 +68,8 @@ index 8f9f759885a9cda57ae7d665ec309a57e12969fd..e096463443639e9eef5311d7154f6d2a
+ // Sakura end - client visibility settings; entity visibility
public TrackedEntity(final Entity entity, final int range, final int updateInterval, final boolean trackDelta) {
this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this::broadcast, this.seenBy); // CraftBukkit
@@ -1234,6 +1267,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this::broadcast, this::broadcastIgnorePlayers, this.seenBy); // Paper
@@ -1304,6 +1337,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);
// Paper end - Configurable entity tracking range by Y
@@ -78,11 +78,11 @@ index 8f9f759885a9cda57ae7d665ec309a57e12969fd..e096463443639e9eef5311d7154f6d2a
if (flag && !player.getBukkitEntity().canSee(this.entity.getBukkitEntity())) { // Paper - only consider hits
flag = false;
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 86792b4573ca12f0b106c3322a0d2678b2634e2a..d22d5252ee7b8932e03a5ebe3ea1b45d26cb5227 100644
index 42f302a4cd2c511609e8818fe29ccd003befc485..59a9632d8fcfacf4828ba4228c813bca730a4c17 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -569,6 +569,21 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
);
@@ -561,6 +561,21 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
this.playerTickingChunks.remove((LevelChunk)chunkHolder.getCurrentChunk());
}
// Paper end - chunk tick iteration
+ // Sakura start - client visibility settings
@@ -103,7 +103,7 @@ index 86792b4573ca12f0b106c3322a0d2678b2634e2a..d22d5252ee7b8932e03a5ebe3ea1b45d
public ServerLevel(
MinecraftServer server,
@@ -681,6 +696,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -671,6 +686,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
this.chunkDataController = new ca.spottedleaf.moonrise.patches.chunk_system.io.datacontroller.ChunkDataController((ServerLevel)(Object)this, this.chunkTaskScheduler);
// Paper end - rewrite chunk system
this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
@@ -111,7 +111,7 @@ index 86792b4573ca12f0b106c3322a0d2678b2634e2a..d22d5252ee7b8932e03a5ebe3ea1b45d
}
// Paper start
@@ -1856,7 +1872,18 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -1876,7 +1892,18 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
for (ServerPlayer serverPlayer : this.players) {
if (serverPlayer.distanceToSqr(vec3) < 4096.0) {
Optional<Vec3> optional = Optional.ofNullable(serverExplosion.getHitPlayers().get(serverPlayer));
@@ -132,19 +132,19 @@ index 86792b4573ca12f0b106c3322a0d2678b2634e2a..d22d5252ee7b8932e03a5ebe3ea1b45d
}
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
index d5dd3f5d4f38ed7281d896275012e3a6697cce9c..ab38dbe13d1dd0c9cb7a4fac223f4b523d550b17 100644
index e281c7da86433c459d917ab92c9509ec29cad595..dbaf6f1f3ce025bad43e80b651495cb519d825b5 100644
--- a/net/minecraft/server/level/ServerPlayer.java
+++ b/net/minecraft/server/level/ServerPlayer.java
@@ -431,6 +431,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
@@ -459,6 +459,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
return this.viewDistanceHolder;
}
// Paper end - rewrite chunk system
public double trackingRangeModifier = 1.0; // Sakura - entity tracking range modifier
+ public final me.samsuik.sakura.player.visibility.PlayerVisibilitySettings visibilitySettings = new me.samsuik.sakura.player.visibility.PlayerVisibilitySettings(); // Sakura - client visibility settings
public ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) {
super(level, level.getSharedSpawnPos(), level.getSharedSpawnAngle(), gameProfile);
diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
index af75f1ca60dc01045f27cb550ac9e3deacf1a1cf..6cfdd613f1dd1d9246b76c865b58412dba2053ce 100644
index d385cb836b7713f2dbd0b8693777c8e5ea0a74e4..81de75ff6726f79b4e9bf1dc1d242b09bb86b4a9 100644
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
@@ -51,6 +51,21 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
@@ -195,22 +195,22 @@ index af75f1ca60dc01045f27cb550ac9e3deacf1a1cf..6cfdd613f1dd1d9246b76c865b58412d
}
}
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 876d207996724727ca26b139af759eab2e6f4131..dabcba79b30c5dd44e61f03cbff94fdbc2681fda 100644
index f49a2c18ec20a7181951389066b7d062b48d43fa..1b89962ac8058c289137da0521b736259ba2443d 100644
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -3205,6 +3205,7 @@ public class ServerGamePacketListenerImpl
@@ -3197,6 +3197,7 @@ public class ServerGamePacketListenerImpl
event.setCancelled(cancelled);
AbstractContainerMenu oldContainer = this.player.containerMenu; // SPIGOT-1224
net.minecraft.world.inventory.AbstractContainerMenu oldContainer = this.player.containerMenu; // SPIGOT-1224
+ me.samsuik.sakura.player.gui.FeatureGui.clickEvent(event); // Sakura - client visibility settings
this.cserver.getPluginManager().callEvent(event);
if (this.player.containerMenu != oldContainer) {
return;
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 30c330cfa6d675eb409b96725248d34474013867..f911d552e5d76c1af29c9abae083fe68cb051749 100644
index 607a3243074d1a67c413d33493fa7b8d9d3055d8..ec7687616eb0bc0f1149d990051a5d67b04edc19 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -523,6 +523,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -512,6 +512,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
}
// Paper end - optimise entity tracker
public boolean pushedByFluid = true; // Sakura - entity pushed by fluid api
@@ -222,10 +222,10 @@ index 30c330cfa6d675eb409b96725248d34474013867..f911d552e5d76c1af29c9abae083fe68
public Entity(EntityType<?> entityType, Level level) {
this.type = entityType;
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
index e80b09ae0b34b5859cff7db350a731a387706ef1..bf5f3db9d62c063e8b880b831edb2f3a43d7005a 100644
index a6922dd8a319511538e9e4dbe92e484d728e445f..6fdcb636e7c4455cec20ebd303da86a71a461afb 100644
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -73,6 +73,7 @@ public class FallingBlockEntity extends Entity {
@@ -75,6 +75,7 @@ public class FallingBlockEntity extends Entity {
public FallingBlockEntity(EntityType<? extends FallingBlockEntity> entityType, Level level) {
super(entityType, level);
this.heightParity = level.sakuraConfig().cannons.mechanics.fallingBlockParity; // Sakura - configure cannon mechanics
@@ -234,10 +234,10 @@ index e80b09ae0b34b5859cff7db350a731a387706ef1..bf5f3db9d62c063e8b880b831edb2f3a
public FallingBlockEntity(Level level, double x, double y, double z, BlockState state) {
diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
index 6f14584c5e06864d449ebc045f4875476bbe4320..c5b9ebbd159284ae2650b0698e06011104d4b70f 100644
index deb5e9e4cdd235311ff4e51ffb2f02f35d580645..7e3d7d5b47557e57bf661aa8d3eefcb416cb408b 100644
--- a/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/net/minecraft/world/entity/item/PrimedTnt.java
@@ -61,6 +61,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -64,6 +64,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
public PrimedTnt(EntityType<? extends PrimedTnt> entityType, Level level) {
super(entityType, level);
this.blocksBuilding = true;

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Load Chunks on Movement
diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
index e04bd54744335fb5398c6e4f7ce8b981f35bfb7d..651a45b795818bd7b1364b95c52570fd99dd35e4 100644
index a97a2a8492f3858e3b622d26768b4d819c9b47a7..44aaaa87d63a2a2287f89feaa431ca0e80da3dab 100644
--- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
+++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
@@ -1885,6 +1885,7 @@ public final class CollisionUtil {
@@ -39,22 +39,22 @@ index e04bd54744335fb5398c6e4f7ce8b981f35bfb7d..651a45b795818bd7b1364b95c52570fd
// bound y
diff --git a/net/minecraft/server/level/TicketType.java b/net/minecraft/server/level/TicketType.java
index 8f12a4df5d63ecd11e6e615d910b6e3f6dde5f3c..56beffa0c5cdb0d6a4836a0ee496bd638432b143 100644
index f91eed907ffc61a4092aabaa0a1b061c2c453673..0159517f425491ce490d982a09e40efd4ce7868c 100644
--- a/net/minecraft/server/level/TicketType.java
+++ b/net/minecraft/server/level/TicketType.java
@@ -21,6 +21,7 @@ public class TicketType<T> {
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<Integer> POST_TELEPORT = TicketType.create("post_teleport", Integer::compare, 5); // Paper - post teleport ticket type
+ public static final TicketType<Long> ENTITY_MOVEMENT = TicketType.create("entity_movement", Long::compareTo, 10*20); // Sakura - load chunks on movement
@@ -51,6 +51,7 @@ public final class TicketType<T> implements ca.spottedleaf.moonrise.patches.chun
public static final TicketType PLUGIN_TICKET = register("plugin_ticket", TicketType.NO_TIMEOUT, false, TicketType.TicketUse.LOADING_AND_SIMULATION); static { ((TicketType<org.bukkit.plugin.Plugin>)PLUGIN_TICKET).moonrise$setIdentifierComparator((org.bukkit.plugin.Plugin p1, org.bukkit.plugin.Plugin p2) -> p1.getName().compareTo(p2.getName())); } // Paper // Paper - rewrite chunk system
public static final TicketType FUTURE_AWAIT = register("future_await", TicketType.NO_TIMEOUT, false, TicketType.TicketUse.LOADING_AND_SIMULATION); // Paper
public static final TicketType CHUNK_LOAD = register("chunk_load", TicketType.NO_TIMEOUT, false, TicketType.TicketUse.LOADING); // Paper - moonrise
+ public static final TicketType ENTITY_MOVEMENT = register("entity_movement", 200L, false, TicketUse.LOADING_AND_SIMULATION); // Sakura - load chunks on movement
public static <T> TicketType<T> create(String name, Comparator<T> comparator) {
return new TicketType<>(name, comparator, 0L);
public static TicketType register(String name, long timeout, boolean persist, TicketType.TicketUse use) {
return Registry.register(BuiltInRegistries.TICKET_TYPE, name, new TicketType(timeout, persist, use));
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 789a64f13185b8d761e290e931ed31f8c04c6255..9bdf3f54198c345e2091835af56b730d6aa4a7ec 100644
index ec7687616eb0bc0f1149d990051a5d67b04edc19..7031f59d7b2b07bffc44d09b9685dc3d779e3afc 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -527,6 +527,20 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -516,6 +516,20 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
public boolean isPrimedTNT;
public boolean isFallingBlock;
// Sakura end - client visibility settings
@@ -75,7 +75,7 @@ index 789a64f13185b8d761e290e931ed31f8c04c6255..9bdf3f54198c345e2091835af56b730d
public Entity(EntityType<?> entityType, Level level) {
this.type = entityType;
@@ -1466,7 +1480,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -1487,7 +1501,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getCollisionsForBlocksOrWorldBorder(
this.level, (Entity)(Object)this, initialCollisionBox, potentialCollisionsVoxel, potentialCollisionsBB,
@@ -84,7 +84,7 @@ index 789a64f13185b8d761e290e931ed31f8c04c6255..9bdf3f54198c345e2091835af56b730d
);
potentialCollisionsBB.addAll(entityAABBs);
final Vec3 collided = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.performCollisions(movement, currentBox, potentialCollisionsVoxel, potentialCollisionsBB);
@@ -4958,13 +4972,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -4931,13 +4945,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@Override
public boolean shouldBeSaved() {
return (this.removalReason == null || this.removalReason.shouldSave())
@@ -101,10 +101,10 @@ index 789a64f13185b8d761e290e931ed31f8c04c6255..9bdf3f54198c345e2091835af56b730d
public boolean mayInteract(ServerLevel level, BlockPos pos) {
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
index bf5f3db9d62c063e8b880b831edb2f3a43d7005a..fcb7b396db2605146be99f2b14da6806cdaa0f44 100644
index 6fdcb636e7c4455cec20ebd303da86a71a461afb..53fce919a6e221aa98cfb0e5a3bb9f673221535e 100644
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -74,6 +74,7 @@ public class FallingBlockEntity extends Entity {
@@ -76,6 +76,7 @@ public class FallingBlockEntity extends Entity {
super(entityType, level);
this.heightParity = level.sakuraConfig().cannons.mechanics.fallingBlockParity; // Sakura - configure cannon mechanics
this.isFallingBlock = true; // Sakura - client visibility settings
@@ -113,10 +113,10 @@ index bf5f3db9d62c063e8b880b831edb2f3a43d7005a..fcb7b396db2605146be99f2b14da6806
public FallingBlockEntity(Level level, double x, double y, double z, BlockState state) {
diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
index c5b9ebbd159284ae2650b0698e06011104d4b70f..3c74cb8d4b71fcfa600742c21d6ad8e3942a2ab7 100644
index 7e3d7d5b47557e57bf661aa8d3eefcb416cb408b..55dbe5baf2df0111d03a43d32208798d7ec670a1 100644
--- a/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/net/minecraft/world/entity/item/PrimedTnt.java
@@ -62,6 +62,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -65,6 +65,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
super(entityType, level);
this.blocksBuilding = true;
this.isPrimedTNT = true; // Sakura - client visibility settings
@@ -125,7 +125,7 @@ index c5b9ebbd159284ae2650b0698e06011104d4b70f..3c74cb8d4b71fcfa600742c21d6ad8e3
public PrimedTnt(Level level, double x, double y, double z, @Nullable LivingEntity owner) {
diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java
index 6d565b52552534ce9cacfc35ad1bf4adcb69eac3..9b42bd1afb9a6c1729cb56e3c232f46112ba57d3 100644
index 3b7f0d5fe40bdda65ab859a0c22bf0d369dc0f01..dd50e4867b16127355243acdb9ba647a4b50baae 100644
--- a/net/minecraft/world/level/chunk/ChunkAccess.java
+++ b/net/minecraft/world/level/chunk/ChunkAccess.java
@@ -138,6 +138,17 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh

View File

@@ -19,7 +19,7 @@ The current packets modified/obfuscated are the following:
# with packets instead of every single player within tracking distance
diff --git a/net/minecraft/network/syncher/SynchedEntityData.java b/net/minecraft/network/syncher/SynchedEntityData.java
index 3d90f9f1ac1bd281edf6bb0f93ea821657d5bd2f..6f3a6efe6624f9d4e500b2eee5d8aed3a6077e71 100644
index f1ab0e66e7d464f7f31a7a360528ed97cdda0aa0..4aed59c3038cb4af7e454a0dd845548884f773aa 100644
--- a/net/minecraft/network/syncher/SynchedEntityData.java
+++ b/net/minecraft/network/syncher/SynchedEntityData.java
@@ -20,6 +20,30 @@ public class SynchedEntityData {
@@ -123,10 +123,10 @@ index 3d90f9f1ac1bd281edf6bb0f93ea821657d5bd2f..6f3a6efe6624f9d4e500b2eee5d8aed3
public DataItem(EntityDataAccessor<T> accessor, T value) {
this.accessor = accessor;
diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java
index 0fb253aa55a24b56b17f524b3261c5b75c7d7e59..8abe899d19434ad4c7cc6c1596bab16df7b14275 100644
index 257ecbcf7d463eefb951867a5426eaf24e356305..ff1c1cd9ff78cdd3492f3c906ba6b8b2da7f1bed 100644
--- a/net/minecraft/server/level/ServerEntity.java
+++ b/net/minecraft/server/level/ServerEntity.java
@@ -138,7 +138,7 @@ public class ServerEntity {
@@ -143,7 +143,7 @@ public class ServerEntity {
this.sendDirtyEntityData();
}
@@ -135,7 +135,7 @@ index 0fb253aa55a24b56b17f524b3261c5b75c7d7e59..8abe899d19434ad4c7cc6c1596bab16d
byte b = Mth.packDegrees(this.entity.getYRot());
byte b1 = Mth.packDegrees(this.entity.getXRot());
boolean flag = Math.abs(b - this.lastSentYRot) >= 1 || Math.abs(b1 - this.lastSentXRot) >= 1;
@@ -404,7 +404,15 @@ public class ServerEntity {
@@ -412,7 +412,15 @@ public class ServerEntity {
List<SynchedEntityData.DataValue<?>> list = entityData.packDirty();
if (list != null) {
this.trackedDataValues = entityData.getNonDefaultValues();
@@ -153,10 +153,10 @@ index 0fb253aa55a24b56b17f524b3261c5b75c7d7e59..8abe899d19434ad4c7cc6c1596bab16d
if (this.entity instanceof LivingEntity) {
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 9bdf3f54198c345e2091835af56b730d6aa4a7ec..63813792c1ae5a27cb42a0acb2c64d1a1e712a05 100644
index 7031f59d7b2b07bffc44d09b9685dc3d779e3afc..b94c17c87628f2ff3aae700f731e7fa5160ed799 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -3492,7 +3492,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -3423,7 +3423,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
this.entityData.markDirty(Entity.DATA_AIR_SUPPLY_ID);
return;
}
@@ -166,7 +166,7 @@ index 9bdf3f54198c345e2091835af56b730d6aa4a7ec..63813792c1ae5a27cb42a0acb2c64d1a
}
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
index fcb7b396db2605146be99f2b14da6806cdaa0f44..b9b8ed9c5e16a703e41997e1a781796363bcf5aa 100644
index 53fce919a6e221aa98cfb0e5a3bb9f673221535e..5cc110d0ce9b63d036e569890acc8a752f5bc477 100644
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -141,7 +141,7 @@ public class FallingBlockEntity extends Entity {
@@ -179,10 +179,10 @@ index fcb7b396db2605146be99f2b14da6806cdaa0f44..b9b8ed9c5e16a703e41997e1a7817963
public BlockPos getStartPos() {
diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
index 3c74cb8d4b71fcfa600742c21d6ad8e3942a2ab7..b6467f9ff64a76104076a01bfd56852ce712d95b 100644
index 55dbe5baf2df0111d03a43d32208798d7ec670a1..0fbac85dd7b624899db3825149a5d2b167ecedaa 100644
--- a/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/net/minecraft/world/entity/item/PrimedTnt.java
@@ -241,7 +241,11 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -243,7 +243,11 @@ public class PrimedTnt extends Entity implements TraceableEntity {
}
public void setFuse(int life) {
@@ -196,10 +196,10 @@ index 3c74cb8d4b71fcfa600742c21d6ad8e3942a2ab7..b6467f9ff64a76104076a01bfd56852c
public int getFuse() {
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
index 4237b743c31f6c6ed0f4c6c69dc4f3007371d77a..102209683ab501b098e4a3f3e30e4aad67a051bd 100644
index 3e17e814d6469e5498add774220ec8b568d09094..2f67228654ab841f26ffb336420d9c4baaaf2442 100644
--- a/net/minecraft/world/entity/player/Player.java
+++ b/net/minecraft/world/entity/player/Player.java
@@ -673,7 +673,7 @@ public abstract class Player extends LivingEntity {
@@ -679,7 +679,7 @@ public abstract class Player extends LivingEntity {
public void increaseScore(int score) {
int score1 = this.getScore();

View File

@@ -1,5 +1,14 @@
++++ REJECTED HUNK: 1
@@ -300,7 +300,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
Date: Mon, 7 Apr 2025 00:29:00 +0100
Subject: [PATCH] Add redstone implementation api
diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java
index ddd70576d1551d77cbefb9d63bbbaf94b569b074..e76b6c44de16f4bf136bc9959f1eedae1492499a 100644
--- a/net/minecraft/world/level/block/RedStoneWireBlock.java
+++ b/net/minecraft/world/level/block/RedStoneWireBlock.java
@@ -275,7 +275,7 @@ public class RedStoneWireBlock extends Block {
* Note: Added 'source' argument so as to help determine direction of information flow
*/
private void updateSurroundingRedstone(Level worldIn, BlockPos pos, BlockState state, @Nullable Orientation orientation, boolean blockAdded) {
@@ -8,10 +17,7 @@
// since 24w33a the source pos is no longer given, but instead an Orientation parameter
// when this is not null, it can be used to find the source pos, which the turbo uses
// to find the direction of information flow
++++ END HUNK
++++ REJECTED HUNK: 2
@@ -373,7 +373,7 @@
@@ -348,7 +348,7 @@ public class RedStoneWireBlock extends Block {
protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) {
if (!oldState.is(state.getBlock()) && !level.isClientSide) {
// Paper start - optimize redstone - replace call to updatePowerStrength
@@ -20,10 +26,7 @@
level.getWireHandler().onWireAdded(pos, state); // Alternate Current
} else {
this.updateSurroundingRedstone(level, pos, state, null, true); // Vanilla/Eigencraft
++++ END HUNK
++++ REJECTED HUNK: 3
@@ -398,7 +398,7 @@
@@ -371,7 +371,7 @@ public class RedStoneWireBlock extends Block {
}
// Paper start - optimize redstone - replace call to updatePowerStrength
@@ -32,10 +35,7 @@
level.getWireHandler().onWireRemoved(pos, state); // Alternate Current
} else {
this.updateSurroundingRedstone(level, pos, state, null, false); // Vanilla/Eigencraft
++++ END HUNK
++++ REJECTED HUNK: 4
@@ -429,7 +429,7 @@
@@ -401,7 +401,7 @@ public class RedStoneWireBlock extends Block {
if (!level.isClientSide) {
// Paper start - optimize redstone (Alternate Current)
// Alternate Current handles breaking of redstone wires in the WireHandler.
@@ -44,4 +44,3 @@
level.getWireHandler().onWireUpdated(pos, state, orientation);
} else
// Paper end - optimize redstone (Alternate Current)
++++ END HUNK

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Optimise paper explosions
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
index d21ce54ebb5724c04eadf56a2cde701d5eeb5db2..f214229185c9b54f54b146487232b432ef1314e6 100644
index ba20e87d2105ce53cdaf4049de2388d05fcd1b56..6e3a429bc165d8473ea50ee2ae1548270db599d1 100644
--- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
@@ -297,6 +297,12 @@ public final class ChunkEntitySlices {
@@ -40,10 +40,10 @@ index d21ce54ebb5724c04eadf56a2cde701d5eeb5db2..f214229185c9b54f54b146487232b432
if (this.count == 0) {
return;
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index df584256e133bfc0b7effd56961f1b91c264c7bd..9f06e32101f494d94d9210210255d5d72ca4ff36 100644
index 340d50be3cc94e47affddd4ad916e1c02e620636..5c029776df58976df6791f66618c97980fbfa4dc 100644
--- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java
@@ -88,7 +88,7 @@ public class ServerExplosion implements Explosion {
@@ -86,7 +86,7 @@ public class ServerExplosion implements Explosion {
}
}
@@ -52,10 +52,10 @@ index df584256e133bfc0b7effd56961f1b91c264c7bd..9f06e32101f494d94d9210210255d5d7
}
private static final int CHUNK_CACHE_SHIFT = 2;
@@ -307,6 +307,39 @@ public class ServerExplosion implements Explosion {
@@ -304,6 +304,39 @@ public class ServerExplosion implements Explosion {
return (float)missedRays / (float)totalRays;
}
// Paper end - collisions optimisations
private final boolean consistentRadius; // Sakura - consistent explosion radius
+ // Sakura start - optimise paper explosions
+ /*
+ * Sort the explosion rays to better utilise the chunk and block cache.
@@ -92,7 +92,7 @@ index df584256e133bfc0b7effd56961f1b91c264c7bd..9f06e32101f494d94d9210210255d5d7
public ServerExplosion(
ServerLevel level,
@@ -398,6 +431,12 @@ public class ServerExplosion implements Explosion {
@@ -395,6 +428,12 @@ public class ServerExplosion implements Explosion {
initialCache = this.getOrCacheExplosionBlock(blockX, blockY, blockZ, key, true);
}
@@ -105,7 +105,7 @@ index df584256e133bfc0b7effd56961f1b91c264c7bd..9f06e32101f494d94d9210210255d5d7
// only ~1/3rd of the loop iterations in vanilla will result in a ray, as it is iterating the perimeter of
// a 16x16x16 cube
// we can cache the rays and their normals as well, so that we eliminate the excess iterations / checks and
@@ -477,16 +516,55 @@ public class ServerExplosion implements Explosion {
@@ -473,16 +512,55 @@ public class ServerExplosion implements Explosion {
// Paper end - collision optimisations
}
@@ -119,7 +119,7 @@ index df584256e133bfc0b7effd56961f1b91c264c7bd..9f06e32101f494d94d9210210255d5d7
int floor3 = Mth.floor(this.center.y + f + 1.0);
int floor4 = Mth.floor(this.center.z - f - 1.0);
int floor5 = Mth.floor(this.center.z + f + 1.0);
- List <Entity> list = this.level.getEntities(excludeSourceFromDamage ? this.source : null, new AABB(floor, floor2, floor4, floor1, floor3, floor5), entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source
- List <Entity> list = this.level.getEntities(this.excludeSourceFromDamage ? this.source : null, new AABB(floor, floor2, floor4, floor1, floor3, floor5), entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source
- for (Entity entity : list) { // Paper - used in loop
+ return new AABB(floor, floor2, floor4, floor1, floor3, floor5);
+ }
@@ -165,9 +165,9 @@ index df584256e133bfc0b7effd56961f1b91c264c7bd..9f06e32101f494d94d9210210255d5d7
if (!entity.ignoreExplosion(this)) {
double d = Math.sqrt(entity.distanceToSqr(this.center)) / f;
if (d <= 1.0) {
@@ -511,15 +589,16 @@ public class ServerExplosion implements Explosion {
// - Damaging EntityEnderDragon does nothing
// - EnderDragon hitbock always covers the other parts and is therefore always present
@@ -507,15 +585,16 @@ public class ServerExplosion implements Explosion {
// - Damaging EnderDragon does nothing
// - EnderDragon hitbox always covers the other parts and is therefore always present
if (entity instanceof EnderDragonPart) {
- continue;
+ return; // Sakura - optimise paper explosions
@@ -181,10 +181,10 @@ index df584256e133bfc0b7effd56961f1b91c264c7bd..9f06e32101f494d94d9210210255d5d7
// Calculate damage separately for each EntityComplexPart
- if (list.contains(dragonPart)) {
+ if (dragonPart.getBoundingBox().intersects(bounds)) { // Sakura - optimise paper explosions
dragonPart.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, f1));
dragonPart.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, dragonPart, f1));
}
}
@@ -528,7 +607,7 @@ public class ServerExplosion implements Explosion {
@@ -524,7 +603,7 @@ public class ServerExplosion implements Explosion {
}
if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Store Entity Data/State
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 63813792c1ae5a27cb42a0acb2c64d1a1e712a05..e37c8b3a4f00dfc6fde1e1fb05cd0bc0cc48377a 100644
index b94c17c87628f2ff3aae700f731e7fa5160ed799..437d10c650f5aea171f2ea0d075f140d7f3cb058 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -541,6 +541,21 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -530,6 +530,21 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return flags;
}
// Sakura end - load chunks on movement
@@ -31,10 +31,10 @@ index 63813792c1ae5a27cb42a0acb2c64d1a1e712a05..e37c8b3a4f00dfc6fde1e1fb05cd0bc0
public Entity(EntityType<?> entityType, Level level) {
this.type = entityType;
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 9fbce0f31a73928a7db752e085fb3d0020fc6387..869670abd843d6c10babf8ffaa7bfc919f8a818a 100644
index 8aea98378fccb14f3eadab72a38e5661806b96c0..e704f4a84167c0cfe5afd99c5f24f6c24d3e4db1 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -1514,6 +1514,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -1498,6 +1498,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
public <T extends Entity> void guardEntityTick(Consumer<T> consumerEntity, T entity) {
try {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Merge Cannon Entities
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index f2c0cd46a64fbc3fc7e6cb77acac353bb84d4073..dc0896f0b857451d6468589e8b44b1b22fa895d0 100644
index 59a9632d8fcfacf4828ba4228c813bca730a4c17..fc70f238f551e819a610c5cf61e3fe4e6a547196 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -697,6 +697,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -687,6 +687,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
// Paper end - rewrite chunk system
this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
this.levelTickScheduler.registerNewTask(this.explosionPositions::clear, 0); // Sakura - client visibility settings
@@ -16,7 +16,7 @@ index f2c0cd46a64fbc3fc7e6cb77acac353bb84d4073..dc0896f0b857451d6468589e8b44b1b2
}
// Paper start
@@ -811,6 +812,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -801,6 +802,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
}
io.papermc.paper.entity.activation.ActivationRange.activateEntities(this); // Paper - EAR
@@ -24,7 +24,7 @@ index f2c0cd46a64fbc3fc7e6cb77acac353bb84d4073..dc0896f0b857451d6468589e8b44b1b2
this.entityTickList
.forEach(
entity -> {
@@ -829,6 +831,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -819,6 +821,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
entity.stopRiding();
}
@@ -41,10 +41,10 @@ index f2c0cd46a64fbc3fc7e6cb77acac353bb84d4073..dc0896f0b857451d6468589e8b44b1b2
this.guardEntityTick(this::tickNonPassenger, entity);
profilerFiller.pop();
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index e37c8b3a4f00dfc6fde1e1fb05cd0bc0cc48377a..272801f1280da06d8e5894d7a3aedd432dfd0911 100644
index 437d10c650f5aea171f2ea0d075f140d7f3cb058..4c4a662306b698112242775f9701902b70e3ae85 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -556,6 +556,24 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -545,6 +545,27 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return to.entityState() != null && to.entityState().comparePositionAndMotion(this);
}
// Sakura end - store entity data/state
@@ -58,9 +58,12 @@ index e37c8b3a4f00dfc6fde1e1fb05cd0bc0cc48377a..272801f1280da06d8e5894d7a3aedd43
+ }
+
+ public final long getPackedOriginPosition() {
+ org.bukkit.util.Vector origin = this.getOriginVector();
+ if (origin != null) {
+ return BlockPos.asLong(origin.getBlockX(), origin.getBlockY(), origin.getBlockZ());
+ if (this.origin != null) {
+ return BlockPos.asLong(
+ Mth.floor(this.origin.x()),
+ Mth.floor(this.origin.y()),
+ Mth.floor(this.origin.z())
+ );
+ } else {
+ return Long.MIN_VALUE;
+ }
@@ -69,7 +72,7 @@ index e37c8b3a4f00dfc6fde1e1fb05cd0bc0cc48377a..272801f1280da06d8e5894d7a3aedd43
public Entity(EntityType<?> entityType, Level level) {
this.type = entityType;
@@ -4957,6 +4975,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -4930,6 +4951,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
this.levelCallback.onRemove(removalReason);
this.onRemoval(removalReason);
@@ -82,19 +85,19 @@ index e37c8b3a4f00dfc6fde1e1fb05cd0bc0cc48377a..272801f1280da06d8e5894d7a3aedd43
if (!(this instanceof ServerPlayer) && removalReason != RemovalReason.CHANGED_DIMENSION && !alreadyRemoved) {
// Players need to be special cased, because they are regularly removed from the world
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
index b9b8ed9c5e16a703e41997e1a781796363bcf5aa..aa81292b862e22e276cabc9d7611362cbd91602d 100644
index 5cc110d0ce9b63d036e569890acc8a752f5bc477..eb2ce73058f9f95989a40ead9c215f07efcb5c18 100644
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -54,7 +54,7 @@ import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.event.entity.EntityRemoveEvent;
// CraftBukkit end
@@ -50,7 +50,7 @@ import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import org.slf4j.Logger;
-public class FallingBlockEntity extends Entity {
+public class FallingBlockEntity extends Entity implements me.samsuik.sakura.entity.merge.MergeableEntity { // Sakura - merge cannon entities
private static final Logger LOGGER = LogUtils.getLogger();
public BlockState blockState = Blocks.SAND.defaultBlockState();
public int time;
@@ -70,11 +70,62 @@ public class FallingBlockEntity extends Entity {
private static final BlockState DEFAULT_BLOCK_STATE = Blocks.SAND.defaultBlockState();
private static final int DEFAULT_TIME = 0;
@@ -72,11 +72,62 @@ public class FallingBlockEntity extends Entity {
public boolean autoExpire = true; // Paper - Expand FallingBlock API
public boolean heightParity; // Sakura - falling block height parity api
@@ -133,7 +136,7 @@ index b9b8ed9c5e16a703e41997e1a781796363bcf5aa..aa81292b862e22e276cabc9d7611362c
+ fallingBlock.entityState().apply(this);
+ break;
+ } else if (count == 0) {
+ this.discard(EntityRemoveEvent.Cause.DESPAWN);
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN);
+ }
+ }
+ }
@@ -165,31 +168,27 @@ index b9b8ed9c5e16a703e41997e1a781796363bcf5aa..aa81292b862e22e276cabc9d7611362c
if (this.level().setBlock(blockPos, this.blockState, 3)) {
((ServerLevel)this.level())
.getChunkSource()
@@ -342,6 +394,7 @@ public class FallingBlockEntity extends Entity {
@@ -340,6 +392,7 @@ public class FallingBlockEntity extends Entity {
compound.putBoolean("CancelDrop", this.cancelDrop);
if (!this.autoExpire) compound.putBoolean("Paper.AutoExpire", false); // Paper - Expand FallingBlock API
+ compound.putInt("merge_count", this.mergeData.getCount()); // Sakura - merge cannon entities
+ compound.putInt("merge_count", this.mergeData.getCount()); // Sakura - merge cannon entities; save to nbt
}
@Override
@@ -374,6 +427,11 @@ public class FallingBlockEntity extends Entity {
this.autoExpire = compound.getBoolean("Paper.AutoExpire");
}
// Paper end - Expand FallingBlock API
+ // Sakura start - merge cannon entities
+ if (compound.contains("merge_count", 3)) {
+ this.mergeData.setCount(compound.getInt("merge_count"));
+ }
+ // Sakura end - merge cannon entities
@@ -355,6 +408,7 @@ public class FallingBlockEntity extends Entity {
this.blockData = compound.getCompound("TileEntityData").map(blockData -> this.level().paperConfig().entities.spawning.filterBadTileEntityNbtFromFallingBlocks && this.blockState.getBlock() instanceof net.minecraft.world.level.block.GameMasterBlock ? null : blockData).map(CompoundTag::copy).orElse(null); // Paper - Filter bad block entity nbt data from falling blocks
this.cancelDrop = compound.getBooleanOr("CancelDrop", false);
this.autoExpire = compound.getBooleanOr("Paper.AutoExpire", true); // Paper - Expand FallingBlock API
+ this.mergeData.setCount(compound.getIntOr("merge_count", 1)); // Sakura - merge cannon entities; load from nbt
}
public void setHurtsEntities(float fallDamagePerDistance, int fallDamageMax) {
diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
index b6467f9ff64a76104076a01bfd56852ce712d95b..e6aa1d1a5fc5cd2ffc156125c4eef2d0d1aeef4a 100644
index 0fbac85dd7b624899db3825149a5d2b167ecedaa..13fdcee0437695ae22180c6091b7aa72a1f1d087 100644
--- a/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/net/minecraft/world/entity/item/PrimedTnt.java
@@ -33,7 +33,7 @@ import org.bukkit.event.entity.EntityRemoveEvent;
@@ -35,7 +35,7 @@ import org.bukkit.event.entity.EntityRemoveEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
// CraftBukkit end
@@ -197,10 +196,10 @@ index b6467f9ff64a76104076a01bfd56852ce712d95b..e6aa1d1a5fc5cd2ffc156125c4eef2d0
+public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sakura.entity.merge.MergeableEntity { // Sakura - merge cannon entities
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 int DEFAULT_FUSE_TIME = 80;
@@ -58,11 +58,48 @@ public class PrimedTnt extends Entity implements TraceableEntity {
private static final short DEFAULT_FUSE_TIME = 80;
@@ -61,11 +61,48 @@ public class PrimedTnt extends Entity implements TraceableEntity {
public float explosionPower = 4.0F;
public boolean isIncendiary = false; // CraftBukkit - add field
public boolean isIncendiary = false; // CraftBukkit
+ // Sakura start - merge cannon entities
+ private final me.samsuik.sakura.entity.merge.MergeEntityData mergeData = new me.samsuik.sakura.entity.merge.MergeEntityData(this);
@@ -247,7 +246,7 @@ index b6467f9ff64a76104076a01bfd56852ce712d95b..e6aa1d1a5fc5cd2ffc156125c4eef2d0
}
public PrimedTnt(Level level, double x, double y, double z, @Nullable LivingEntity owner) {
@@ -142,6 +179,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -145,6 +182,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
if (i <= 0) {
// CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event
//this.discard();
@@ -255,31 +254,27 @@ index b6467f9ff64a76104076a01bfd56852ce712d95b..e6aa1d1a5fc5cd2ffc156125c4eef2d0
if (!this.level().isClientSide) {
this.explode();
}
@@ -212,6 +250,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -218,6 +256,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
if (this.explosionPower != 4.0F) {
compound.putFloat("explosion_power", this.explosionPower);
}
+ compound.putInt("merge_count", this.mergeData.getCount()); // Sakura - merge cannon entities
+ compound.putInt("merge_count", this.mergeData.getCount()); // Sakura - merge cannon entities; save to nbt
}
@Override
@@ -224,6 +263,11 @@ public class PrimedTnt extends Entity implements TraceableEntity {
if (compound.contains("explosion_power", 99)) {
this.explosionPower = Mth.clamp(compound.getFloat("explosion_power"), 0.0F, 128.0F);
}
+ // Sakura start - merge cannon entities
+ if (compound.contains("merge_count", 3)) {
+ this.mergeData.setCount(compound.getInt("merge_count"));
+ }
+ // Sakura end - merge cannon entities
@@ -226,6 +265,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
this.setFuse(compound.getShortOr("fuse", (short)80));
this.setBlockState(compound.read("block_state", BlockState.CODEC, registryOps).orElse(DEFAULT_BLOCK_STATE));
this.explosionPower = Mth.clamp(compound.getFloatOr("explosion_power", 4.0F), 0.0F, 128.0F);
+ this.mergeData.setCount(compound.getIntOr("merge_count", 1)); // Sakura - merge cannon entities; load from nbt
}
@Nullable
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 869670abd843d6c10babf8ffaa7bfc919f8a818a..5c4c2823ec6b5e2d9293b9130ddf2bc1c3c12048 100644
index e704f4a84167c0cfe5afd99c5f24f6c24d3e4db1..37271a9e9d3d16a01c437629806508accefa1b9c 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -841,6 +841,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -828,6 +828,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
public final me.samsuik.sakura.listener.LevelTickScheduler levelTickScheduler = new me.samsuik.sakura.listener.LevelTickScheduler();
public final me.samsuik.sakura.listener.BlockChangeTracker blockChangeTracker = new me.samsuik.sakura.listener.BlockChangeTracker(this);
// Sakura end - track block changes and tick scheduler
@@ -288,10 +283,10 @@ index 869670abd843d6c10babf8ffaa7bfc919f8a818a..5c4c2823ec6b5e2d9293b9130ddf2bc1
protected Level(
WritableLevelData levelData,
diff --git a/net/minecraft/world/level/block/BasePressurePlateBlock.java b/net/minecraft/world/level/block/BasePressurePlateBlock.java
index 108c1d23bf80777b943edfa0b5585ebb928540a7..69d490c79e30fb42da69bbd804ecaea7b88fe7b0 100644
index 42ee3f32fe44c1f0680c994a69201f7bd7792673..96c977df11c660ccb9a9b32e61c865084e3776ce 100644
--- a/net/minecraft/world/level/block/BasePressurePlateBlock.java
+++ b/net/minecraft/world/level/block/BasePressurePlateBlock.java
@@ -91,7 +91,7 @@ public abstract class BasePressurePlateBlock extends Block {
@@ -92,7 +92,7 @@ public abstract class BasePressurePlateBlock extends Block {
}
private void checkPressed(@Nullable Entity entity, Level level, BlockPos pos, BlockState state, int currentSignal) {
@@ -300,7 +295,7 @@ index 108c1d23bf80777b943edfa0b5585ebb928540a7..69d490c79e30fb42da69bbd804ecaea7
boolean flag = currentSignal > 0;
boolean flag1 = signalStrength > 0;
@@ -168,6 +168,12 @@ public abstract class BasePressurePlateBlock extends Block {
@@ -162,6 +162,12 @@ public abstract class BasePressurePlateBlock extends Block {
// CraftBukkit end
}
@@ -314,10 +309,10 @@ index 108c1d23bf80777b943edfa0b5585ebb928540a7..69d490c79e30fb42da69bbd804ecaea7
protected abstract int getSignalForState(BlockState state);
diff --git a/net/minecraft/world/level/block/WeightedPressurePlateBlock.java b/net/minecraft/world/level/block/WeightedPressurePlateBlock.java
index 0ad494a861c04aeacb0620000e306cfab813fdde..c49044097fa8d3294de10a681717cd424e6c1078 100644
index 5e095919828e89d12f2676b3c544842a81e047a1..94d699f1b8b1a85ea36341985666b21fcaaac761 100644
--- a/net/minecraft/world/level/block/WeightedPressurePlateBlock.java
+++ b/net/minecraft/world/level/block/WeightedPressurePlateBlock.java
@@ -40,6 +40,11 @@ public class WeightedPressurePlateBlock extends BasePressurePlateBlock {
@@ -39,6 +39,11 @@ public class WeightedPressurePlateBlock extends BasePressurePlateBlock {
@Override
protected int getSignalStrength(Level level, BlockPos pos) {
@@ -329,7 +324,7 @@ index 0ad494a861c04aeacb0620000e306cfab813fdde..c49044097fa8d3294de10a681717cd42
// CraftBukkit start
// int min = Math.min(getEntityCount(level, TOUCH_AABB.move(pos), Entity.class), this.maxWeight);
int min = 0;
@@ -55,7 +60,7 @@ public class WeightedPressurePlateBlock extends BasePressurePlateBlock {
@@ -54,7 +59,7 @@ public class WeightedPressurePlateBlock extends BasePressurePlateBlock {
// We only want to block turning the plate on if all events are cancelled
if (!cancellable.isCancelled()) {
@@ -337,4 +332,4 @@ index 0ad494a861c04aeacb0620000e306cfab813fdde..c49044097fa8d3294de10a681717cd42
+ min += !entityInside && entity instanceof me.samsuik.sakura.entity.merge.MergeableEntity mergeEntity ? mergeEntity.getMergeEntityData().getCount() : 1; // Sakura - merge cannon entities
}
}
// CraftBukkit end

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Replace explosion density cache
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 8fec4a46a9cf13d832306bd87a4fe17be79bef86..dce3331c7dbbf9bb6c6342d0a760c040342a2d0c 100644
index fc70f238f551e819a610c5cf61e3fe4e6a547196..50bf6d317d5574e26cbfff431711cb6a5a1310c4 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -698,6 +698,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -688,6 +688,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
this.levelTickScheduler.registerNewTask(this.explosionPositions::clear, 0); // Sakura - client visibility settings
this.levelTickScheduler.registerNewTask(this.mergeHandler::expire, 200); // Sakura - merge cannon entities
@@ -17,10 +17,10 @@ index 8fec4a46a9cf13d832306bd87a4fe17be79bef86..dce3331c7dbbf9bb6c6342d0a760c040
// Paper start
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 5c4c2823ec6b5e2d9293b9130ddf2bc1c3c12048..125f61e6560790bed25e2f7aedaa189caf31a8aa 100644
index 37271a9e9d3d16a01c437629806508accefa1b9c..d111bd5546613cefd8b4070788679901b7e5b8f4 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -842,6 +842,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -829,6 +829,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
public final me.samsuik.sakura.listener.BlockChangeTracker blockChangeTracker = new me.samsuik.sakura.listener.BlockChangeTracker(this);
// Sakura end - track block changes and tick scheduler
public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities
@@ -29,10 +29,10 @@ index 5c4c2823ec6b5e2d9293b9130ddf2bc1c3c12048..125f61e6560790bed25e2f7aedaa189c
protected Level(
WritableLevelData levelData,
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index 9f06e32101f494d94d9210210255d5d72ca4ff36..6d3e03b3c9fed817808de6ee08b531069d342dd5 100644
index 5c029776df58976df6791f66618c97980fbfa4dc..38657fa606ae34a3bb752fcd01f7aa732fe17c7e 100644
--- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java
@@ -296,7 +296,12 @@ public class ServerExplosion implements Explosion {
@@ -294,7 +294,12 @@ public class ServerExplosion implements Explosion {
Math.fma(dz, diffZ, offZ)
);
@@ -46,7 +46,7 @@ index 9f06e32101f494d94d9210210255d5d72ca4ff36..6d3e03b3c9fed817808de6ee08b53106
++missedRays;
}
}
@@ -385,8 +390,16 @@ public class ServerExplosion implements Explosion {
@@ -382,8 +387,16 @@ public class ServerExplosion implements Explosion {
double d9 = Mth.lerp(d6, boundingBox.minY, boundingBox.maxY);
double d10 = Mth.lerp(d7, boundingBox.minZ, boundingBox.maxZ);
Vec3 vec3 = new Vec3(d8 + d3, d9, d10 + d4);
@@ -65,7 +65,7 @@ index 9f06e32101f494d94d9210210255d5d72ca4ff36..6d3e03b3c9fed817808de6ee08b53106
i++;
}
@@ -691,6 +704,11 @@ public class ServerExplosion implements Explosion {
@@ -679,6 +692,11 @@ public class ServerExplosion implements Explosion {
return;
}
// CraftBukkit end
@@ -77,7 +77,7 @@ index 9f06e32101f494d94d9210210255d5d72ca4ff36..6d3e03b3c9fed817808de6ee08b53106
for (BlockPos blockPos : blocks) {
// CraftBukkit start - TNTPrimeEvent
@@ -857,14 +875,12 @@ public class ServerExplosion implements Explosion {
@@ -844,14 +862,12 @@ public class ServerExplosion implements Explosion {
// Paper start - Optimize explosions
protected float getBlockDensity(Vec3 vec3d, Entity entity) {
@@ -98,10 +98,10 @@ index 9f06e32101f494d94d9210210255d5d72ca4ff36..6d3e03b3c9fed817808de6ee08b53106
return blockDensity;
diff --git a/net/minecraft/world/level/block/BasePressurePlateBlock.java b/net/minecraft/world/level/block/BasePressurePlateBlock.java
index 69d490c79e30fb42da69bbd804ecaea7b88fe7b0..497409e04dc4b9366da1fbe0641b8424c727a176 100644
index 96c977df11c660ccb9a9b32e61c865084e3776ce..dc110835679dbfcb232c58c91ddac343c85ee3ab 100644
--- a/net/minecraft/world/level/block/BasePressurePlateBlock.java
+++ b/net/minecraft/world/level/block/BasePressurePlateBlock.java
@@ -109,6 +109,11 @@ public abstract class BasePressurePlateBlock extends Block {
@@ -107,6 +107,11 @@ public abstract class BasePressurePlateBlock extends Block {
// CraftBukkit end
if (currentSignal != signalStrength) {
BlockState blockState = this.setSignalForState(state, signalStrength);
@@ -114,10 +114,10 @@ index 69d490c79e30fb42da69bbd804ecaea7b88fe7b0..497409e04dc4b9366da1fbe0641b8424
this.updateNeighbours(level, pos);
level.setBlocksDirty(pos, state, blockState);
diff --git a/net/minecraft/world/level/block/TripWireHookBlock.java b/net/minecraft/world/level/block/TripWireHookBlock.java
index 30b97cdcd495490ef65c2ab9dfc39a39c93002ca..e57cc9f0987d9d4cda888bc633e5f24e510ec709 100644
index 8a3a8b0fdf9545a41501dc992c6982d9c8ce7b66..5e2576a8b90de8a829c6136cc384f3fe5a49603c 100644
--- a/net/minecraft/world/level/block/TripWireHookBlock.java
+++ b/net/minecraft/world/level/block/TripWireHookBlock.java
@@ -182,6 +182,11 @@ public class TripWireHookBlock extends Block {
@@ -168,6 +168,11 @@ public class TripWireHookBlock extends Block {
if (!cancelledReceiverHook) { // always trigger two events even when the first hook current change is cancelled
// Paper end - Call BlockRedstoneEvent
Direction opposite = direction.getOpposite();
@@ -130,14 +130,13 @@ index 30b97cdcd495490ef65c2ab9dfc39a39c93002ca..e57cc9f0987d9d4cda888bc633e5f24e
notifyNeighbors(block, level, blockPosx, opposite);
emitState(level, blockPosx, flag2, flag3, flag, flag1);
diff --git a/net/minecraft/world/phys/AABB.java b/net/minecraft/world/phys/AABB.java
index 85148858db1fd5e9da8bbdde4b0d84110d80e373..23d5a2726f6113eaa79196ac6f6b8db85e386f97 100644
index c22acc8889fbb3c9ee698624189c195ee4b5eefb..b08ab87278023e50c56a381240712cc2e18a0440 100644
--- a/net/minecraft/world/phys/AABB.java
+++ b/net/minecraft/world/phys/AABB.java
@@ -442,4 +442,28 @@ public class AABB {
center.x - xSize / 2.0, center.y - ySize / 2.0, center.z - zSize / 2.0, center.x + xSize / 2.0, center.y + ySize / 2.0, center.z + zSize / 2.0
);
}
+
@@ -19,6 +19,30 @@ public class AABB {
public final double maxY;
public final double maxZ;
+ // Sakura start - explosion density cache
+ public final boolean isAABBInBounds(AABB bb) {
+ return this.minX <= bb.minX && this.maxX >= bb.maxX
@@ -161,4 +160,7 @@ index 85148858db1fd5e9da8bbdde4b0d84110d80e373..23d5a2726f6113eaa79196ac6f6b8db8
+ return new AABB(minX, minY, minZ, maxX, maxY, maxZ);
+ }
+ // Sakura end - explosion density cache
}
+
public AABB(double x1, double y1, double z1, double x2, double y2, double z2) {
this.minX = Math.min(x1, x2);
this.minY = Math.min(y1, y2);

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Optimise explosions in protected regions
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index 6d3e03b3c9fed817808de6ee08b531069d342dd5..76697d12a12eeedbaab6aef169080320791aff6e 100644
index 38657fa606ae34a3bb752fcd01f7aa732fe17c7e..c597226b6a90ab687d176fe63e21c9c2cd71c7e1 100644
--- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java
@@ -345,6 +345,22 @@ public class ServerExplosion implements Explosion {
@@ -342,6 +342,22 @@ public class ServerExplosion implements Explosion {
return rays;
}
// Sakura end - optimise paper explosions
@@ -21,7 +21,7 @@ index 6d3e03b3c9fed817808de6ee08b531069d342dd5..76697d12a12eeedbaab6aef169080320
+ 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);
+ blocks.add(location.getBlock());
+ EntityExplodeEvent event = CraftEventFactory.callEntityExplodeEvent(this.source, blocks, 0.0f, this.blockInteraction);
+ org.bukkit.event.entity.EntityExplodeEvent event = CraftEventFactory.callEntityExplodeEvent(this.source, blocks, 0.0f, this.blockInteraction);
+ return !event.isCancelled() && !event.blockList().isEmpty();
+ }
+
@@ -31,7 +31,7 @@ index 6d3e03b3c9fed817808de6ee08b531069d342dd5..76697d12a12eeedbaab6aef169080320
public ServerExplosion(
ServerLevel level,
@@ -449,6 +465,11 @@ public class ServerExplosion implements Explosion {
@@ -446,6 +462,11 @@ public class ServerExplosion implements Explosion {
return ret;
}
// Sakura end - optimise paper explosions

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Specialised Explosions
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index a826ddc16ce9e646c6d552381ee85eaa4d523436..ce89182a48b7f89b2223407cc907f0572e777598 100644
index 50bf6d317d5574e26cbfff431711cb6a5a1310c4..effdd0e1382fc59b9d8a709c18a652fbd4e94e6d 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -1871,7 +1871,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -1891,7 +1891,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
case STANDARD -> Explosion.BlockInteraction.DESTROY; // CraftBukkit - handle custom explosion type
};
Vec3 vec3 = new Vec3(x, y, z);
@@ -26,7 +26,7 @@ index a826ddc16ce9e646c6d552381ee85eaa4d523436..ce89182a48b7f89b2223407cc907f057
if (configurator != null) configurator.accept(serverExplosion);// Paper - Allow explosions to damage source
serverExplosion.explode();
// CraftBukkit start
@@ -1879,6 +1888,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -1899,6 +1908,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
return serverExplosion;
}
// CraftBukkit end
@@ -42,7 +42,7 @@ index a826ddc16ce9e646c6d552381ee85eaa4d523436..ce89182a48b7f89b2223407cc907f057
ParticleOptions particleOptions = serverExplosion.isSmall() ? smallExplosionParticles : largeExplosionParticles;
for (ServerPlayer serverPlayer : this.players) {
@@ -1899,7 +1917,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -1919,7 +1937,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
}
}
@@ -52,10 +52,10 @@ index a826ddc16ce9e646c6d552381ee85eaa4d523436..ce89182a48b7f89b2223407cc907f057
private Explosion.BlockInteraction getDestroyType(GameRules.Key<GameRules.BooleanValue> decayGameRule) {
diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
index e6aa1d1a5fc5cd2ffc156125c4eef2d0d1aeef4a..cb972f9d619c7acc8bbed4cc18513ad4b97f19ed 100644
index 13fdcee0437695ae22180c6091b7aa72a1f1d087..57cfc90b3193fe8603cf10c444ae9be6dce8e584 100644
--- a/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/net/minecraft/world/entity/item/PrimedTnt.java
@@ -77,20 +77,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
@@ -80,20 +80,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
@Override
public final void respawnEntity(int count) {
@@ -78,10 +78,10 @@ index e6aa1d1a5fc5cd2ffc156125c4eef2d0d1aeef4a..cb972f9d619c7acc8bbed4cc18513ad4
// Sakura end - merge cannon entities
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index bdd60268dfe82988fb9a86bb524706c807dac237..04a0f15e25e0746c638b8b01671adb579d0b0209 100644
index c597226b6a90ab687d176fe63e21c9c2cd71c7e1..6510ce55b9590fbfa50b70b56180840abf565731 100644
--- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java
@@ -361,6 +361,38 @@ public class ServerExplosion implements Explosion {
@@ -358,6 +358,38 @@ public class ServerExplosion implements Explosion {
return true;
}
// Sakura end - optimise explosion protected regions
@@ -120,19 +120,19 @@ index bdd60268dfe82988fb9a86bb524706c807dac237..04a0f15e25e0746c638b8b01671adb57
public ServerExplosion(
ServerLevel level,
@@ -670,7 +702,10 @@ public class ServerExplosion implements Explosion {
if (entity instanceof Player) {
Player player = (Player)entity;
if (!player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Option to disable explosion knockback
@@ -664,7 +696,10 @@ public class ServerExplosion implements Explosion {
// CraftBukkit end
entity.push(vec3);
if (entity instanceof Player player && !player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Option to disable explosion knockback
- this.hitPlayers.put(player, vec3);
+ // Sakura start - specialised explosions; tally player velocity
+ final Vec3 explosionImpact = vec3;
+ this.hitPlayers.compute(player, (p, v) -> v != null ? v.add(explosionImpact) : explosionImpact);
+ // Sakura end - specialised explosions; tally player velocity
}
}
@@ -779,14 +814,7 @@ public class ServerExplosion implements Explosion {
entity.onExplosionHit(this.source);
@@ -767,14 +802,7 @@ public class ServerExplosion implements Explosion {
return;
}
// CraftBukkit end
@@ -148,7 +148,7 @@ index bdd60268dfe82988fb9a86bb524706c807dac237..04a0f15e25e0746c638b8b01671adb57
this.level.gameEvent(this.source, GameEvent.EXPLODE, this.center);
List<BlockPos> list = this.calculateExplodedPositions();
this.hurtEntities();
@@ -800,13 +828,7 @@ public class ServerExplosion implements Explosion {
@@ -788,13 +816,7 @@ public class ServerExplosion implements Explosion {
if (this.fire) {
this.createFire(list);
}

View File

@@ -5,19 +5,19 @@ Subject: [PATCH] Optimise cannon entity movement
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 272801f1280da06d8e5894d7a3aedd432dfd0911..a1e65255f23ec2e3b2e3dfd9092fc16638493d92 100644
index 4c4a662306b698112242775f9701902b70e3ae85..f7ba5db617582b16c5d101259dc60349fcdadd22 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -1180,7 +1180,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -1165,7 +1165,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
Vec3 vec3 = this.collide(movement);
double d = vec3.lengthSqr();
if (d > 1.0E-7 || movement.lengthSqr() - d < 1.0E-7) {
- if (this.fallDistance != 0.0F && d >= 1.0) {
+ if (this.fallDistance != 0.0F && d >= 1.0 && !this.isFallingBlock) { // Sakura - optimise cannon entity movement
- if (this.fallDistance != 0.0 && d >= 1.0) {
+ if (this.fallDistance != 0.0 && d >= 1.0 && !this.isFallingBlock) { // Sakura - optimise cannon entity movement
BlockHitResult blockHitResult = this.level()
.clip(
new ClipContext(this.position(), this.position().add(vec3), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this)
@@ -1482,6 +1482,131 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -1506,6 +1506,131 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return distance;
}
@@ -150,10 +150,10 @@ index 272801f1280da06d8e5894d7a3aedd432dfd0911..a1e65255f23ec2e3b2e3dfd9092fc166
protected Vec3 collide(Vec3 movement) {
final boolean xZero = movement.x == 0.0;
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
index aa81292b862e22e276cabc9d7611362cbd91602d..bf6473756594f3296160d3b8c28a24ef0e458328 100644
index eb2ce73058f9f95989a40ead9c215f07efcb5c18..767bcc16b79d1a82fc9a73ab7b022c84aa66ede3 100644
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -119,6 +119,12 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
@@ -121,6 +121,12 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
return itemEntity;
}
// Sakura end - merge cannon entities
@@ -167,10 +167,10 @@ index aa81292b862e22e276cabc9d7611362cbd91602d..bf6473756594f3296160d3b8c28a24ef
public FallingBlockEntity(EntityType<? extends FallingBlockEntity> entityType, Level level) {
super(entityType, level);
diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
index cb972f9d619c7acc8bbed4cc18513ad4b97f19ed..d23193d3f11505cea428414487f891ab584ad071 100644
index 57cfc90b3193fe8603cf10c444ae9be6dce8e584..a5fdbd843ad49a862508574c1b07a2503c019f96 100644
--- a/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/net/minecraft/world/entity/item/PrimedTnt.java
@@ -80,6 +80,12 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
@@ -83,6 +83,12 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
this.mergeData.setCount(count); // Sakura - specialised explosions
}
// Sakura end - merge cannon entities

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Add maxSearch to getEntities
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
index f214229185c9b54f54b146487232b432ef1314e6..a242b68b6d603d3da46d9e0635a86a07a7149b3b 100644
index 6e3a429bc165d8473ea50ee2ae1548270db599d1..417afe621f559d7fab0798ccf586b630e8878b23 100644
--- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
@@ -314,7 +314,14 @@ public final class ChunkEntitySlices {
@@ -83,10 +83,10 @@ index 7554c109c35397bc1a43dd80e87764fd78645bbf..d60f30f7afb15cc90c1bd4b816136d00
}
}
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 125f61e6560790bed25e2f7aedaa189caf31a8aa..dc3c1d354bd4fb557f295c8dca14a31048def456 100644
index d111bd5546613cefd8b4070788679901b7e5b8f4..99571af2e473cb14322625b0287b2f18fcf116d3 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -1795,10 +1795,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -1779,10 +1779,18 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
this.getEntities(entityTypeTest, bounds, predicate, output, Integer.MAX_VALUE);
}
@@ -106,7 +106,7 @@ index 125f61e6560790bed25e2f7aedaa189caf31a8aa..dc3c1d354bd4fb557f295c8dca14a310
Profiler.get().incrementCounter("getEntities");
if (entityTypeTest instanceof net.minecraft.world.entity.EntityType<T> byType) {
@@ -1815,7 +1823,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -1799,7 +1807,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
if (entityTypeTest == null) {
if (maxCount != Integer.MAX_VALUE) {

View File

@@ -0,0 +1,29 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
Date: Thu, 23 Sep 2021 18:50:13 +0100
Subject: [PATCH] Use maxEntityCollision limit for entity retrieval
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
index d4276654fe855d0f73b8c02f5576b69f48c269dd..3634a31f8ab0930bd4a5e249b7686036b0948f20 100644
--- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java
@@ -3691,7 +3691,17 @@ public abstract class LivingEntity extends Entity implements Attackable {
return;
}
// Paper end - don't run getEntities if we're not going to use its result
- List<Entity> pushableEntities = this.level().getPushableEntities(this, this.getBoundingBox());
+ // Sakura start - use maxEntityCollision limit for entity retrieval
+ //List<Entity> pushableEntities = this.level().getPushableEntities(this, this.getBoundingBox());
+ final int limit = Math.max(_int, this.level().paperConfig().collisions.maxEntityCollisions);
+ final int search = limit * limit;
+ final List<Entity> pushableEntities = new java.util.ArrayList<>(4);
+ this.level().getEntities(
+ net.minecraft.world.level.entity.EntityTypeTest.forClass(Entity.class),
+ this.getBoundingBox(), EntitySelector.pushableBy(this),
+ pushableEntities, limit, search
+ );
+ // Sakura end - use maxEntityCollision limit for entity retrieval
if (!pushableEntities.isEmpty()) {
if (this.level() instanceof ServerLevel serverLevel) {
// Paper - don't run getEntities if we're not going to use its result; moved up

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Explosion Durable Blocks
diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java
index 68e50c6ade879d263424f244070677cb81c34c33..8467af4ee57b6699227370ada7bf15ca41fb91c3 100644
index 2fbbbac9f1472354bd507926a85c25f48291edfe..e11f4c722b132340b9a48915bddf5ec6e55239ed 100644
--- a/net/minecraft/world/item/BlockItem.java
+++ b/net/minecraft/world/item/BlockItem.java
@@ -45,8 +45,31 @@ public class BlockItem extends Item {
@@ -38,8 +38,31 @@ public class BlockItem extends Item {
this.block = block;
}
@@ -41,10 +41,10 @@ index 68e50c6ade879d263424f244070677cb81c34c33..8467af4ee57b6699227370ada7bf15ca
return !interactionResult.consumesAction() && context.getItemInHand().has(DataComponents.CONSUMABLE)
? super.use(context.getLevel(), context.getPlayer(), context.getHand())
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index dc3c1d354bd4fb557f295c8dca14a31048def456..f7a341082d78667d34e7832f4567bbf4f3f86a00 100644
index 99571af2e473cb14322625b0287b2f18fcf116d3..769887ee6d798d0b11de72e9ffe80c9d358daf17 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -843,6 +843,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -830,6 +830,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
// Sakura end - track block changes and tick scheduler
public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities
public final me.samsuik.sakura.explosion.density.BlockDensityCache densityCache = new me.samsuik.sakura.explosion.density.BlockDensityCache(); // Sakura - explosion density cache
@@ -53,10 +53,10 @@ index dc3c1d354bd4fb557f295c8dca14a31048def456..f7a341082d78667d34e7832f4567bbf4
protected Level(
WritableLevelData levelData,
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index 0285e19d6265056fb5ff9855a5dd41bd16bbc082..2d0a2f6dc9c02a86b443ccdab2eeba283eb2d229 100644
index 6510ce55b9590fbfa50b70b56180840abf565731..ba067476b418fa81952a9f59528ca75eefd13746 100644
--- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java
@@ -133,7 +133,7 @@ public class ServerExplosion implements Explosion {
@@ -131,7 +131,7 @@ public class ServerExplosion implements Explosion {
BlockState blockState = ((ca.spottedleaf.moonrise.patches.getblock.GetBlockChunk)chunk).moonrise$getBlock(x, y, z);
FluidState fluidState = blockState.getFluidState();
@@ -65,7 +65,7 @@ index 0285e19d6265056fb5ff9855a5dd41bd16bbc082..2d0a2f6dc9c02a86b443ccdab2eeba28
ret = new ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache(
key, pos, blockState, fluidState,
@@ -393,6 +393,20 @@ public class ServerExplosion implements Explosion {
@@ -390,6 +390,20 @@ public class ServerExplosion implements Explosion {
// Paper end - collision optimisations
}
// Sakura end - specialised explosions
@@ -86,7 +86,7 @@ index 0285e19d6265056fb5ff9855a5dd41bd16bbc082..2d0a2f6dc9c02a86b443ccdab2eeba28
public ServerExplosion(
ServerLevel level,
@@ -779,6 +793,14 @@ public class ServerExplosion implements Explosion {
@@ -767,6 +781,14 @@ public class ServerExplosion implements Explosion {
}
}
// CraftBukkit end

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Destroy Waterlogged Blocks
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index 2d0a2f6dc9c02a86b443ccdab2eeba283eb2d229..7b5a50ef269d0ca59fb067258421b53971a9998d 100644
index ba067476b418fa81952a9f59528ca75eefd13746..65d2b93a6ca6f18aae72627b7a21215eecdcc9c2 100644
--- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java
@@ -402,6 +402,11 @@ public class ServerExplosion implements Explosion {
@@ -399,6 +399,11 @@ public class ServerExplosion implements Explosion {
if (material != null && material.resistance() >= 0.0f && pos.getY() > this.level.getMinY() && (this.level.sakuraConfig().cannons.explosion.allowNonTntBreakingDurableBlocks || this.source instanceof net.minecraft.world.entity.item.PrimedTnt)) {
return Optional.of(material.resistance());
}

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Configure cannon physics
diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
index 651a45b795818bd7b1364b95c52570fd99dd35e4..47c8ed946cb2ad81a4469daf60dabc40c5e8beda 100644
index 44aaaa87d63a2a2287f89feaa431ca0e80da3dab..194db5ff2a473b10fded4491c1173d420f46424d 100644
--- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
+++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
@@ -1774,6 +1774,13 @@ public final class CollisionUtil {
@@ -67,10 +67,10 @@ index 651a45b795818bd7b1364b95c52570fd99dd35e4..47c8ed946cb2ad81a4469daf60dabc40
if (xSmaller && z != 0.0) {
z = performAABBCollisionsZ(axisalignedbb, z, aabbs);
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 1fbe5ebf133a80390d0dc3c89f8742476bf76866..f86943ad2582d6c6d656078b15ab83e8b75f39c5 100644
index f7ba5db617582b16c5d101259dc60349fcdadd22..10c0bb5d1d88500e0002a726401a18313f5b3aaa 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -574,6 +574,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -566,6 +566,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
}
}
// Sakura end - merge cannon entities
@@ -84,7 +84,7 @@ index 1fbe5ebf133a80390d0dc3c89f8742476bf76866..f86943ad2582d6c6d656078b15ab83e8
public Entity(EntityType<?> entityType, Level level) {
this.type = entityType;
@@ -1086,7 +1093,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -1085,7 +1092,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
}
protected void checkSupportingBlock(boolean onGround, @Nullable Vec3 movement) {
@@ -93,33 +93,32 @@ index 1fbe5ebf133a80390d0dc3c89f8742476bf76866..f86943ad2582d6c6d656078b15ab83e8
AABB boundingBox = this.getBoundingBox();
AABB aabb = new AABB(boundingBox.minX, boundingBox.minY - 1.0E-6, boundingBox.minZ, boundingBox.maxX, boundingBox.minY, boundingBox.maxZ);
Optional<BlockPos> optional = this.level.findSupportingBlock(this, aabb);
@@ -1152,7 +1159,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -1135,7 +1142,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
if (this.noPhysics) {
this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z);
} else {
this.wasOnFire = this.isOnFire();
- if (type == MoverType.PISTON) {
+ // Sakura start - configure cannon physics
+ final me.samsuik.sakura.physics.PhysicsVersion physics = this.physics;
+ if (type == MoverType.PISTON && physics.afterOrEqual(1_11_0)) {
+ // Sakura end - configure cannon physics
this.activatedTick = Math.max(this.activatedTick, MinecraftServer.currentTick + 20); // Paper - EAR 2
this.activatedImmunityTick = Math.max(this.activatedImmunityTick, MinecraftServer.currentTick + 20); // Paper - EAR 2
movement = this.limitPistonMovement(movement);
@@ -1179,8 +1189,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
// Paper start - EAR 2
this.activatedTick = Math.max(this.activatedTick, MinecraftServer.currentTick + 20);
this.activatedImmunityTick = Math.max(this.activatedImmunityTick, MinecraftServer.currentTick + 20);
@@ -1164,8 +1174,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
movement = this.maybeBackOffFromEdge(movement, type);
Vec3 vec3 = this.collide(movement);
double d = vec3.lengthSqr();
- if (d > 1.0E-7 || movement.lengthSqr() - d < 1.0E-7) {
- if (this.fallDistance != 0.0F && d >= 1.0 && !this.isFallingBlock) { // Sakura - optimise cannon entity movement
+
- if (this.fallDistance != 0.0 && d >= 1.0 && !this.isFallingBlock) { // Sakura - optimise cannon entity movement
+ // Sakura start - configure cannon physics
+ if (d > 1.0E-7 || physics.afterOrEqual(1_21_2) && movement.lengthSqr() - d < 1.0E-7 || physics.before(1_14_0)) {
+ if (this.fallDistance != 0.0F && d >= 1.0 && !this.isFallingBlock && physics.afterOrEqual(1_18_2)) { // Sakura - optimise cannon entity movement
+ if (this.fallDistance != 0.0 && d >= 1.0 && !this.isFallingBlock && physics.afterOrEqual(1_18_2)) { // Sakura - optimise cannon entity movement
+ // Sakura end - configure cannon physics
BlockHitResult blockHitResult = this.level()
.clip(
new ClipContext(this.position(), this.position().add(vec3), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this)
@@ -1221,6 +1234,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -1219,6 +1231,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
} else {
if (this.horizontalCollision) {
Vec3 deltaMovement = this.getDeltaMovement();
@@ -132,7 +131,7 @@ index 1fbe5ebf133a80390d0dc3c89f8742476bf76866..f86943ad2582d6c6d656078b15ab83e8
this.setDeltaMovement(flag ? 0.0 : deltaMovement.x, deltaMovement.y, flag1 ? 0.0 : deltaMovement.z);
}
@@ -1511,7 +1530,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -1535,7 +1553,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
bb = currBoundingBox.expandTowards(movement.x, movement.y, movement.z);
}
this.collectCollisions(bb, voxelList, bbList, ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER);
@@ -141,7 +140,7 @@ index 1fbe5ebf133a80390d0dc3c89f8742476bf76866..f86943ad2582d6c6d656078b15ab83e8
}
private Vec3 collideAxisScan(Vec3 movement, AABB currBoundingBox, List<VoxelShape> voxelList, List<AABB> bbList) {
@@ -1519,7 +1538,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -1543,7 +1561,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
double y = movement.y;
double z = movement.z;
@@ -153,7 +152,7 @@ index 1fbe5ebf133a80390d0dc3c89f8742476bf76866..f86943ad2582d6c6d656078b15ab83e8
if (y != 0.0) {
y = this.scanY(currBoundingBox, y, voxelList, bbList);
@@ -1641,7 +1663,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -1665,7 +1686,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER | this.getExtraCollisionFlags(), null // Sakura - load chunks on movement
);
potentialCollisionsBB.addAll(entityAABBs);
@@ -162,32 +161,28 @@ index 1fbe5ebf133a80390d0dc3c89f8742476bf76866..f86943ad2582d6c6d656078b15ab83e8
final boolean collidedX = collided.x != movement.x;
final boolean collidedY = collided.y != movement.y;
@@ -1800,9 +1822,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -1791,11 +1812,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
for (Entity.Movement movement : movements) {
Vec3 vec3 = movement.from();
Vec3 vec31 = movement.to();
- AABB aabb = this.makeBoundingBox(vec31).deflate(1.0E-5F);
-
- for (BlockPos blockPos : BlockGetter.boxTraverseBlocks(vec3, vec31, aabb)) {
+ // Sakura start - configure cannon physics
+ double margin = this.physics.afterOrEqual(1_21_2) ? 1.0E-5f : this.physics.afterOrEqual(1_19_3) ? 1.0E-7 : 0.001;
+ AABB aabb = this.makeBoundingBox(vec31).deflate(margin);
+ final Iterable<BlockPos> positions;
+ if (this.physics.afterOrEqual(1_21_2)) {
+ positions = BlockGetter.boxTraverseBlocks(vec3, vec31, aabb);
+ } else {
+ positions = BlockPos.betweenClosed(aabb);
+ }
+ for (BlockPos blockPos : positions) {
+ // Sakura end - configure cannon physics
if (!this.isAlive()) {
return;
}
BlockGetter.forEachBlockIntersectedBetween(
vec3,
vec31,
aabb,
+ this.physics, // Sakura - configure cannon physics
(pos, step) -> {
if (this.isAlive()) {
BlockState blockState = this.level().getBlockState(pos);
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
index bf6473756594f3296160d3b8c28a24ef0e458328..e4e708609799799ed2e7dd516ba8bf61e98bc022 100644
index 767bcc16b79d1a82fc9a73ab7b022c84aa66ede3..029ef84a62683fa75b4222a11d09925f54d2fd55 100644
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -125,6 +125,43 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
@@ -127,6 +127,43 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
return this.sakura_collide(movement);
}
// Sakura end - optimise cannon entity movement
@@ -218,20 +213,20 @@ index bf6473756594f3296160d3b8c28a24ef0e458328..e4e708609799799ed2e7dd516ba8bf61
+ BlockPos blockposition = this.blockPosition();
+ BlockState blockstate = this.level().getBlockState(blockposition);
+
+ if (blockstate.is(block) && CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState())) {
+ if (blockstate.is(block) && org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState())) {
+ this.level().removeBlock(blockposition, false);
+ } else {
+ if (blockstate.is(block)) {
+ ((ServerLevel) this.level()).getChunkSource().blockChanged(blockposition);
+ }
+ this.discard(EntityRemoveEvent.Cause.DESPAWN);
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN);
+ }
+ }
+ // Sakura end - configure cannon physics
public FallingBlockEntity(EntityType<? extends FallingBlockEntity> entityType, Level level) {
super(entityType, level);
@@ -144,6 +181,10 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
@@ -146,6 +183,10 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
this.yo = y;
this.zo = z;
this.setStartPos(this.blockPosition());
@@ -243,9 +238,9 @@ index bf6473756594f3296160d3b8c28a24ef0e458328..e4e708609799799ed2e7dd516ba8bf61
// Sakura start - falling block height parity api
@@ -178,7 +219,11 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
: blockState
blockState.hasProperty(BlockStateProperties.WATERLOGGED) ? blockState.setValue(BlockStateProperties.WATERLOGGED, false) : blockState
);
if (!CraftEventFactory.callEntityChangeBlockEvent(fallingBlockEntity, pos, blockState.getFluidState().createLegacyBlock())) return fallingBlockEntity; // CraftBukkit
if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(fallingBlockEntity, pos, blockState.getFluidState().createLegacyBlock())) return fallingBlockEntity; // CraftBukkit
- level.setBlock(pos, blockState.getFluidState().createLegacyBlock(), 3);
+ // Sakura start - configure cannon physics
+ if (fallingBlockEntity.physics.afterOrEqual(1_18_2)) {
@@ -265,7 +260,7 @@ index bf6473756594f3296160d3b8c28a24ef0e458328..e4e708609799799ed2e7dd516ba8bf61
@Override
@@ -231,6 +276,12 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
} else {
Block block = this.blockState.getBlock();
+ // Sakura start - configure cannon physics
@@ -308,7 +303,7 @@ index bf6473756594f3296160d3b8c28a24ef0e458328..e4e708609799799ed2e7dd516ba8bf61
if (!this.cancelDrop) {
boolean canBeReplaced = blockState.canBeReplaced(
new DirectionalPlaceContext(this.level(), blockPos, Direction.DOWN, ItemStack.EMPTY, Direction.UP)
@@ -346,7 +407,12 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
@@ -343,7 +404,12 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
}
}
@@ -323,10 +318,10 @@ index bf6473756594f3296160d3b8c28a24ef0e458328..e4e708609799799ed2e7dd516ba8bf61
}
diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
index d23193d3f11505cea428414487f891ab584ad071..f7e63da492136299a0c494dd58c0b181f2fe425a 100644
index a5fdbd843ad49a862508574c1b07a2503c019f96..6153f82d85b73a927c5a4cf6b916c69d06edd744 100644
--- a/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/net/minecraft/world/entity/item/PrimedTnt.java
@@ -86,6 +86,22 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
@@ -89,6 +89,22 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
return this.sakura_collide(movement);
}
// Sakura end - optimise cannon entity movement
@@ -349,7 +344,7 @@ index d23193d3f11505cea428414487f891ab584ad071..f7e63da492136299a0c494dd58c0b181
public PrimedTnt(EntityType<? extends PrimedTnt> entityType, Level level) {
super(entityType, level);
@@ -111,6 +127,13 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
@@ -114,6 +130,13 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
case Y -> this.setDeltaMovement(this.getDeltaMovement().multiply(0.0, 1.0, 0.0));
}
// Sakura end - configure cannon mechanics
@@ -363,7 +358,7 @@ index d23193d3f11505cea428414487f891ab584ad071..f7e63da492136299a0c494dd58c0b181
}
// Sakura start - optimise tnt fluid state
@@ -146,7 +169,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
@@ -149,7 +172,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
@Override
protected double getDefaultGravity() {
@@ -372,7 +367,7 @@ index d23193d3f11505cea428414487f891ab584ad071..f7e63da492136299a0c494dd58c0b181
}
@Override
@@ -162,14 +185,19 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
@@ -165,14 +188,19 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
return;
}
// Paper end - Configurable TNT height nerf
@@ -395,11 +390,11 @@ index d23193d3f11505cea428414487f891ab584ad071..f7e63da492136299a0c494dd58c0b181
// 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.respawnEntity(); // Sakura - merge cannon entities
@@ -222,13 +250,14 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
@@ -226,13 +254,14 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
return;
}
// CraftBukkit end
+ double explosionY = this.physics.before(1_10_0) ? this.getY() + (double) 0.49f : this.getY(0.0625D); // Sakura - configure cannon physics
+ final double explosionY = this.physics.before(1_10_0) ? this.getY() + (double) 0.49f : this.getY(0.0625D); // Sakura - configure cannon physics
this.level()
.explode(
this,
@@ -411,7 +406,7 @@ index d23193d3f11505cea428414487f891ab584ad071..f7e63da492136299a0c494dd58c0b181
this.getZ(),
event.getRadius(), // CraftBukkit
event.getFire(), // CraftBukkit
@@ -320,7 +349,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
@@ -318,7 +347,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
// Paper start - Option to prevent TNT from moving in water
@Override
public boolean isPushedByFluid() {
@@ -420,11 +415,31 @@ index d23193d3f11505cea428414487f891ab584ad071..f7e63da492136299a0c494dd58c0b181
}
// Paper end - Option to prevent TNT from moving in water
}
diff --git a/net/minecraft/world/level/BlockGetter.java b/net/minecraft/world/level/BlockGetter.java
index dd7e32b8b176c0f4c13e50aeed33c2c9ccba4b53..673e07e24c0cc0bc8301a15ca028c0bd72a3439c 100644
--- a/net/minecraft/world/level/BlockGetter.java
+++ b/net/minecraft/world/level/BlockGetter.java
@@ -213,8 +213,14 @@ public interface BlockGetter extends LevelHeightAccessor {
}
static void forEachBlockIntersectedBetween(Vec3 from, Vec3 to, AABB boundingBox, BlockGetter.BlockStepVisitor stepVisitor) {
+ // Sakura start - configure cannon physics
+ forEachBlockIntersectedBetween(from, to, boundingBox, null, stepVisitor);
+ }
+
+ static void forEachBlockIntersectedBetween(Vec3 from, Vec3 to, AABB boundingBox, me.samsuik.sakura.physics.PhysicsVersion physics, BlockGetter.BlockStepVisitor stepVisitor) {
Vec3 vec3 = to.subtract(from);
- if (!(vec3.lengthSqr() < Mth.square(0.99999F))) {
+ if ((physics == null || physics.afterOrEqual(1_21_2)) && !(vec3.lengthSqr() < Mth.square(0.99999F))) {
+ // Sakura end - configure cannon physics
LongSet set = new LongOpenHashSet();
Vec3 minPosition = boundingBox.getMinPosition();
Vec3 vec31 = minPosition.subtract(vec3);
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index facca2c0d42598d16453f3e6c2dbb13f2696aba5..5dee39586c9d59bfcadbd7d97726a308812fca78 100644
index 65d2b93a6ca6f18aae72627b7a21215eecdcc9c2..26cd9559013ca2bb17b98f2675e7c43f76519d8b 100644
--- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java
@@ -412,6 +412,7 @@ public class ServerExplosion implements Explosion {
@@ -409,6 +409,7 @@ public class ServerExplosion implements Explosion {
return this.damageCalculator.getBlockExplosionResistance(this, this.level, pos, blockState, fluidState);
}
// Sakura end - explosion durable blocks
@@ -432,7 +447,7 @@ index facca2c0d42598d16453f3e6c2dbb13f2696aba5..5dee39586c9d59bfcadbd7d97726a308
public ServerExplosion(
ServerLevel level,
@@ -433,6 +434,7 @@ public class ServerExplosion implements Explosion {
@@ -430,6 +431,7 @@ public class ServerExplosion implements Explosion {
this.damageCalculator = damageCalculator == null ? this.makeDamageCalculator(source) : damageCalculator;
this.yield = this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F; // CraftBukkit
this.consistentRadius = level.localConfig().config(BlockPos.containing(this.center)).consistentRadius; // Sakura - consistent explosion radius
@@ -440,7 +455,7 @@ index facca2c0d42598d16453f3e6c2dbb13f2696aba5..5dee39586c9d59bfcadbd7d97726a308
}
private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) {
@@ -462,8 +464,13 @@ public class ServerExplosion implements Explosion {
@@ -459,8 +461,13 @@ public class ServerExplosion implements Explosion {
final float density = entity.level().densityCache.getKnownDensity(vec3);
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;
@@ -455,7 +470,7 @@ index facca2c0d42598d16453f3e6c2dbb13f2696aba5..5dee39586c9d59bfcadbd7d97726a308
}
if (hitResult == HitResult.Type.MISS) {
// Sakura end - replace density cache
@@ -562,6 +569,15 @@ public class ServerExplosion implements Explosion {
@@ -558,6 +565,15 @@ public class ServerExplosion implements Explosion {
}
if (cachedBlock.outOfWorld) {
@@ -471,7 +486,7 @@ index facca2c0d42598d16453f3e6c2dbb13f2696aba5..5dee39586c9d59bfcadbd7d97726a308
break;
}
final BlockState iblockdata = cachedBlock.blockState;
@@ -657,6 +673,12 @@ public class ServerExplosion implements Explosion {
@@ -653,6 +669,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 squareRoot = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3);
@@ -484,7 +499,7 @@ index facca2c0d42598d16453f3e6c2dbb13f2696aba5..5dee39586c9d59bfcadbd7d97726a308
if (squareRoot != 0.0) {
d1 /= squareRoot;
d2 /= squareRoot;
@@ -948,7 +970,7 @@ public class ServerExplosion implements Explosion {
@@ -935,7 +957,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) {
@@ -493,7 +508,7 @@ index facca2c0d42598d16453f3e6c2dbb13f2696aba5..5dee39586c9d59bfcadbd7d97726a308
this.level.densityCache.putDensity(vec3d, entity, blockDensity);
// Sakura end - replace density cache
}
@@ -956,6 +978,16 @@ public class ServerExplosion implements Explosion {
@@ -943,6 +965,16 @@ public class ServerExplosion implements Explosion {
return blockDensity;
}
@@ -511,7 +526,7 @@ index facca2c0d42598d16453f3e6c2dbb13f2696aba5..5dee39586c9d59bfcadbd7d97726a308
private final Level world;
private final double posX, posY, posZ;
diff --git a/net/minecraft/world/level/block/FallingBlock.java b/net/minecraft/world/level/block/FallingBlock.java
index 1a787426acb68cf8f9491bdd8f903c7e0c00e29f..d410720b27d97dae2a7bbc4455f227064759001a 100644
index 4fa238d1cd6b19f16c0d0a8a9a913e9e42debbed..4f9626be4e97483259f569af01aa05fc0860f87a 100644
--- a/net/minecraft/world/level/block/FallingBlock.java
+++ b/net/minecraft/world/level/block/FallingBlock.java
@@ -45,6 +45,15 @@ public abstract class FallingBlock extends Block implements Fallable {
@@ -531,32 +546,32 @@ index 1a787426acb68cf8f9491bdd8f903c7e0c00e29f..d410720b27d97dae2a7bbc4455f22706
protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
if (isFree(level.getBlockState(pos.below())) && pos.getY() >= level.getMinY()) {
diff --git a/net/minecraft/world/level/block/FenceGateBlock.java b/net/minecraft/world/level/block/FenceGateBlock.java
index 438f1492ab5b8c7bb2a32828c83e8178c2e04712..81f94bf9351355640c1ffd214638035c6582d87a 100644
index a5e686b90e532e3b656fca411936499c2b2020c7..0644841408cae93fe6175a7b9a01980fa9e5c140 100644
--- a/net/minecraft/world/level/block/FenceGateBlock.java
+++ b/net/minecraft/world/level/block/FenceGateBlock.java
@@ -224,8 +224,14 @@ public class FenceGateBlock extends HorizontalDirectionalBlock {
@@ -210,8 +210,14 @@ public class FenceGateBlock extends HorizontalDirectionalBlock {
hasNeighborSignal = eventRedstone.getNewCurrent() > 0;
}
// CraftBukkit end
- if (state.getValue(POWERED) != hasNeighborSignal) {
- level.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(hasNeighborSignal)).setValue(OPEN, Boolean.valueOf(hasNeighborSignal)), 2);
- level.setBlock(pos, state.setValue(POWERED, hasNeighborSignal).setValue(OPEN, hasNeighborSignal), 2);
+ // Sakura start - configure cannon physics
+ final boolean legacy = level.localConfig().config(pos).physicsVersion.before(1_11_0);
+ final boolean powered = state.getValue(POWERED);
+ if (legacy ? (hasNeighborSignal || neighborBlock.defaultBlockState().isSignalSource()) : powered != hasNeighborSignal) {
+ final boolean openGate = legacy && (hasNeighborSignal == powered || state.getValue(OPEN) != powered)
+ ? state.getValue(OPEN) : hasNeighborSignal;
+ level.setBlock(pos, (state.setValue(POWERED, hasNeighborSignal)).setValue(OPEN, openGate), 2);
+ level.setBlock(pos, state.setValue(POWERED, hasNeighborSignal).setValue(OPEN, openGate), 2);
+ // Sakura end - configure cannon physics
if (state.getValue(OPEN) != hasNeighborSignal) {
level.playSound(
null,
diff --git a/net/minecraft/world/level/block/HoneyBlock.java b/net/minecraft/world/level/block/HoneyBlock.java
index bab3ac2c4be08ea7589752b8472c1e13bcaab76a..fdf8306a569edd074d0debeb07be67da9ada5e77 100644
index a98c308c5febd458d6489174b94898cd4b9bae69..adc022ccfd3ad6e6372e25fe0b6a21c4d486b08c 100644
--- a/net/minecraft/world/level/block/HoneyBlock.java
+++ b/net/minecraft/world/level/block/HoneyBlock.java
@@ -70,11 +70,19 @@ public class HoneyBlock extends HalfTransparentBlock {
super.entityInside(state, level, pos, entity);
@@ -71,11 +71,19 @@ public class HoneyBlock extends HalfTransparentBlock {
super.entityInside(state, level, pos, entity, effectApplier);
}
- private static double getOldDeltaY(double deltaY) {
@@ -577,7 +592,7 @@ index bab3ac2c4be08ea7589752b8472c1e13bcaab76a..fdf8306a569edd074d0debeb07be67da
return (deltaY - 0.08) * 0.98F;
}
@@ -83,7 +91,7 @@ public class HoneyBlock extends HalfTransparentBlock {
@@ -84,7 +92,7 @@ public class HoneyBlock extends HalfTransparentBlock {
return false;
} else if (entity.getY() > pos.getY() + 0.9375 - 1.0E-7) {
return false;
@@ -586,7 +601,7 @@ index bab3ac2c4be08ea7589752b8472c1e13bcaab76a..fdf8306a569edd074d0debeb07be67da
return false;
} else {
double abs = Math.abs(pos.getX() + 0.5 - entity.getX());
@@ -101,11 +109,13 @@ public class HoneyBlock extends HalfTransparentBlock {
@@ -102,11 +110,13 @@ public class HoneyBlock extends HalfTransparentBlock {
private void doSlideMovement(Entity entity) {
Vec3 deltaMovement = entity.getDeltaMovement();
@@ -605,52 +620,39 @@ index bab3ac2c4be08ea7589752b8472c1e13bcaab76a..fdf8306a569edd074d0debeb07be67da
entity.resetFallDistance();
diff --git a/net/minecraft/world/level/block/LadderBlock.java b/net/minecraft/world/level/block/LadderBlock.java
index 352aa47ba6d4e434bcf2af8e70c5abcb734056eb..c615d4fa56d9237f9b71800ee77f6be219ce18c7 100644
index f9c305de60a323b450a26c9d7de50a824492cf5a..d40879dc8b8d7366a7dfd5e67630c9472f23f68a 100644
--- a/net/minecraft/world/level/block/LadderBlock.java
+++ b/net/minecraft/world/level/block/LadderBlock.java
@@ -35,6 +35,21 @@ public class LadderBlock extends Block implements SimpleWaterloggedBlock {
private static final VoxelShape SOUTH_AABB_COPY = SOUTH_AABB.copy();
private static final VoxelShape NORTH_AABB_COPY = NORTH_AABB.copy();
// Sakura end - protect block shapes against plugins
+ // Sakura start - configure cannon physics
+ 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_SOUTH_AABB = Block.box(0.0, 0.0, 0.0, 16.0, 16.0, 2.0);
+ protected static final VoxelShape LEGACY_NORTH_AABB = Block.box(0.0, 0.0, 14.0, 16.0, 16.0, 16.0);
+
+ private static VoxelShape legacyShape(Direction facing) {
+ return switch (facing) {
+ case NORTH -> LEGACY_NORTH_AABB;
+ case SOUTH -> LEGACY_SOUTH_AABB;
+ case WEST -> LEGACY_WEST_AABB;
+ default -> LEGACY_EAST_AABB;
+ };
+ }
+ // Sakura end - configure cannon physics
@Override
public MapCodec<LadderBlock> codec() {
@@ -46,8 +61,18 @@ public class LadderBlock extends Block implements SimpleWaterloggedBlock {
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(WATERLOGGED, Boolean.valueOf(false)));
@@ -33,6 +33,15 @@ public class LadderBlock extends Block implements SimpleWaterloggedBlock {
return CODEC;
}
+ // Sakura start - configure cannon physics
+ public static final Map<Direction, VoxelShape> LEGACY_SHAPES = Shapes.rotateHorizontal(Block.boxZ(16.0, 14.0, 16.0));
+
+ @Override
+ public final boolean hasDynamicShape() {
+ public boolean hasDynamicShape() {
+ return true;
+ }
+ // Sakura end - configure cannon physics
+
protected LadderBlock(BlockBehaviour.Properties properties) {
super(properties);
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(WATERLOGGED, false));
@@ -40,6 +49,11 @@ public class LadderBlock extends Block implements SimpleWaterloggedBlock {
@Override
protected VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
+ // Sakura start - configure cannon physics
+ if (level instanceof net.minecraft.world.level.Level gameLevel && gameLevel.localConfig().config(pos).physicsVersion.before(1_9_0)) {
+ return legacyShape(state.getValue(FACING));
+ return LEGACY_SHAPES.get(state.getValue(FACING));
+ }
+ // Sakura end - configure cannon physics
switch ((Direction)state.getValue(FACING)) {
case NORTH:
// Sakura start - protect block shapes against plugins
return SHAPES.get(state.getValue(FACING));
}
diff --git a/net/minecraft/world/level/block/LiquidBlock.java b/net/minecraft/world/level/block/LiquidBlock.java
index fa94f79349483b3ad3676183fa9ee22dabd803df..b9b9f1a47cba3c72a306ec54896690701b76d34d 100644
index 4dbbfa34c085fd9777de5b4a6bf48dedfe8603b8..1e8574d7900ffde16c2e1ee9f92a77c47c85af61 100644
--- a/net/minecraft/world/level/block/LiquidBlock.java
+++ b/net/minecraft/world/level/block/LiquidBlock.java
@@ -195,7 +195,20 @@ public class LiquidBlock extends Block implements BucketPickup {
@@ -673,13 +675,13 @@ index fa94f79349483b3ad3676183fa9ee22dabd803df..b9b9f1a47cba3c72a306ec5489669070
+ }
+ // Sakura end - configure cannon physics
// CraftBukkit start
if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, block.defaultBlockState())) {
if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, block.defaultBlockState(), 3)) {
this.fizz(level, pos);
diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java
index 945f34971680bb1c90ea133431c900ad1b5a8ced..31a76dc1ee4a02ad91637b27d1927b5a5d38ddb3 100644
index e76b6c44de16f4bf136bc9959f1eedae1492499a..270c405a7384e3290b4eea58e0b231aa6235d85a 100644
--- a/net/minecraft/world/level/block/RedStoneWireBlock.java
+++ b/net/minecraft/world/level/block/RedStoneWireBlock.java
@@ -572,6 +572,10 @@ public class RedStoneWireBlock extends Block {
@@ -544,6 +544,10 @@ public class RedStoneWireBlock extends Block {
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) {
if (!player.getAbilities().mayBuild) {
return InteractionResult.PASS;
@@ -691,41 +693,42 @@ index 945f34971680bb1c90ea133431c900ad1b5a8ced..31a76dc1ee4a02ad91637b27d1927b5a
if (isCross(state) || isDot(state)) {
BlockState blockState = isCross(state) ? this.defaultBlockState() : this.crossState;
diff --git a/net/minecraft/world/level/block/WaterlilyBlock.java b/net/minecraft/world/level/block/WaterlilyBlock.java
index f085671bcef6dd9758240f91dfe7c58ef6212f0b..1209bc07200ea1c1752e578363fee9d5d3f542b2 100644
index 3b3047aa1198754e64913634f76fdc015c1fe07d..0fe59a797f4ff1462a72492e6ffe32df50607756 100644
--- a/net/minecraft/world/level/block/WaterlilyBlock.java
+++ b/net/minecraft/world/level/block/WaterlilyBlock.java
@@ -17,6 +17,7 @@ import net.minecraft.world.phys.shapes.VoxelShape;
public class WaterlilyBlock extends BushBlock {
public static final MapCodec<WaterlilyBlock> CODEC = simpleCodec(WaterlilyBlock::new);
protected static final VoxelShape AABB = Block.box(1.0, 0.0, 1.0, 15.0, 1.5, 15.0);
+ protected static final VoxelShape LEGACY_AABB = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 0.25D, 16.0D); // Sakura - configure cannon physics
@Override
public MapCodec<WaterlilyBlock> codec() {
@@ -41,8 +42,18 @@ public class WaterlilyBlock extends BushBlock {
}
@@ -24,6 +24,15 @@ public class WaterlilyBlock extends VegetationBlock {
return CODEC;
}
+ // Sakura start - configure cannon physics
+ protected static final VoxelShape LEGACY_SHAPE = Block.column(16.0, 0.0, 0.25);
+
+ @Override
+ public final boolean hasDynamicShape() {
+ public boolean hasDynamicShape() {
+ return true;
+ }
+ // Sakura end - configure cannon physics
+
protected WaterlilyBlock(BlockBehaviour.Properties properties) {
super(properties);
}
@@ -44,6 +53,11 @@ public class WaterlilyBlock extends VegetationBlock {
@Override
protected VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
+ // Sakura start - configure cannon physics
+ if (level instanceof net.minecraft.world.level.Level gameLevel && gameLevel.localConfig().config(pos).physicsVersion.before(1_9_0)) {
+ return LEGACY_AABB;
+ return LEGACY_SHAPE;
+ }
+ // Sakura end - configure cannon physics
return AABB;
return SHAPE;
}
diff --git a/net/minecraft/world/level/block/piston/MovingPistonBlock.java b/net/minecraft/world/level/block/piston/MovingPistonBlock.java
index f14e84e67746208dd188525fb91ab30b190d332b..1d66e5848a7f1b3c5e6b70f2e38351667f62ee25 100644
index 05bbc2e59384702439548a988e128a85f1adbe82..7d84bb8b2e155785152d58ed39af0c3328c30203 100644
--- a/net/minecraft/world/level/block/piston/MovingPistonBlock.java
+++ b/net/minecraft/world/level/block/piston/MovingPistonBlock.java
@@ -110,6 +110,16 @@ public class MovingPistonBlock extends BaseEntityBlock {
@@ -100,6 +100,16 @@ public class MovingPistonBlock extends BaseEntityBlock {
@Override
protected VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
PistonMovingBlockEntity blockEntity = this.getBlockEntity(level, pos);
@@ -743,10 +746,10 @@ index f14e84e67746208dd188525fb91ab30b190d332b..1d66e5848a7f1b3c5e6b70f2e3835166
}
diff --git a/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/net/minecraft/world/level/block/piston/PistonBaseBlock.java
index 0208a21f1984fff141eb079169bf269d61c26d3d..99b1551df53e42a7e0a6b1fd35603e4500676739 100644
index c372c9f828f52af0d31cc9d20c00359fdb2a610a..3bf8045f77216d06683e749c35733969be5b37b3 100644
--- a/net/minecraft/world/level/block/piston/PistonBaseBlock.java
+++ b/net/minecraft/world/level/block/piston/PistonBaseBlock.java
@@ -145,6 +145,11 @@ public class PistonBaseBlock extends DirectionalBlock {
@@ -122,6 +122,11 @@ public class PistonBaseBlock extends DirectionalBlock {
i = 2;
}
@@ -759,10 +762,10 @@ index 0208a21f1984fff141eb079169bf269d61c26d3d..99b1551df53e42a7e0a6b1fd35603e45
}
}
diff --git a/net/minecraft/world/level/block/piston/PistonHeadBlock.java b/net/minecraft/world/level/block/piston/PistonHeadBlock.java
index a89a42a3ad6cecd5cc4d44e4456d52a2997ba2e5..9c3c0305aa96b4a1b40841d1c1f145af8e86af40 100644
index 6c789e56f21f01252c21786cfeb48d88485b5636..17ecdee7bd6a8369394115d6534c9d7e9a21e9ee 100644
--- a/net/minecraft/world/level/block/piston/PistonHeadBlock.java
+++ b/net/minecraft/world/level/block/piston/PistonHeadBlock.java
@@ -151,6 +151,11 @@ public class PistonHeadBlock extends DirectionalBlock {
@@ -105,6 +105,11 @@ public class PistonHeadBlock extends DirectionalBlock {
@Override
protected boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) {
BlockState blockState = level.getBlockState(pos.relative(state.getValue(FACING).getOpposite()));
@@ -774,7 +777,7 @@ index a89a42a3ad6cecd5cc4d44e4456d52a2997ba2e5..9c3c0305aa96b4a1b40841d1c1f145af
return this.isFittingBase(state, blockState) || blockState.is(Blocks.MOVING_PISTON) && blockState.getValue(FACING) == state.getValue(FACING);
}
@@ -162,6 +167,10 @@ public class PistonHeadBlock extends DirectionalBlock {
@@ -116,6 +121,10 @@ public class PistonHeadBlock extends DirectionalBlock {
neighborBlock,
ExperimentalRedstoneUtils.withFront(orientation, state.getValue(FACING).getOpposite())
);
@@ -786,24 +789,11 @@ index a89a42a3ad6cecd5cc4d44e4456d52a2997ba2e5..9c3c0305aa96b4a1b40841d1c1f145af
}
diff --git a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
index d1fdb60b3dbcfc244c16d6f61802774ec54cc6ec..466f77b85df0b45cd4a971710fdb99aae555c0fc 100644
index 7277004b03287fdf9f3345d445740af27f02d772..c1ea33dc297409a8da73ee5145d800a4715b93ea 100644
--- a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
+++ b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
@@ -165,6 +165,12 @@ public class PistonMovingBlockEntity extends BlockEntity {
double d4 = 0.0;
+ // Sakura start - configure cannon physics
+ if (entity.physics().before(1_11_0)) {
+ moveEntityByPistonFromDirection(movementDirection, entity, aabb);
+ return;
+ }
+ // Sakura end - configure cannon physics
for (AABB aabb1 : list) {
AABB movementArea = PistonMath.getMovementArea(moveByPositionAndProgress(pos, aabb1, piston), movementDirection, d);
AABB boundingBox = entity.getBoundingBox();
@@ -292,17 +298,170 @@ public class PistonMovingBlockEntity extends BlockEntity {
}
@@ -65,6 +65,150 @@ public class PistonMovingBlockEntity extends BlockEntity {
this.isSourcePiston = isSourcePiston;
}
+ // Sakura start - configure cannon physics
@@ -950,8 +940,23 @@ index d1fdb60b3dbcfc244c16d6f61802774ec54cc6ec..466f77b85df0b45cd4a971710fdb99aa
+ }
+ // Sakura end - configure cannon physics
+
public Direction getPushDirection() {
return this.extending ? this.direction : this.direction.getOpposite();
@Override
public CompoundTag getUpdateTag(HolderLookup.Provider registries) {
return this.saveCustomOnly(registries);
@@ -169,6 +313,12 @@ public class PistonMovingBlockEntity extends BlockEntity {
double d4 = 0.0;
+ // Sakura start - configure cannon physics
+ if (entity.physics().before(1_11_0)) {
+ moveEntityByPistonFromDirection(movementDirection, entity, aabb);
+ return;
+ }
+ // Sakura end - configure cannon physics
for (AABB aabb1 : list) {
AABB movementArea = PistonMath.getMovementArea(moveByPositionAndProgress(pos, aabb1, piston), movementDirection, d);
AABB boundingBox = entity.getBoundingBox();
@@ -308,12 +458,21 @@ public class PistonMovingBlockEntity extends BlockEntity {
}
public static void tick(Level level, BlockPos pos, BlockState state, PistonMovingBlockEntity blockEntity) {
@@ -973,7 +978,7 @@ index d1fdb60b3dbcfc244c16d6f61802774ec54cc6ec..466f77b85df0b45cd4a971710fdb99aa
level.removeBlockEntity(pos);
blockEntity.setRemoved();
if (level.getBlockState(pos).is(Blocks.MOVING_PISTON)) {
@@ -324,12 +483,22 @@ public class PistonMovingBlockEntity extends BlockEntity {
@@ -335,12 +494,22 @@ public class PistonMovingBlockEntity extends BlockEntity {
}
} else {
float f = blockEntity.progress + 0.5F;
@@ -997,10 +1002,10 @@ index d1fdb60b3dbcfc244c16d6f61802774ec54cc6ec..466f77b85df0b45cd4a971710fdb99aa
}
diff --git a/net/minecraft/world/level/material/LavaFluid.java b/net/minecraft/world/level/material/LavaFluid.java
index 3ee197e533460ef4fa87bebe18d02ffc76de8550..9b714ddad7208dd9509bf9f8434f1acea5a6f213 100644
index 48124dd5cc7461ffbcf741b1f0161ef9e1580158..34a40cf00c4337acd716358f7767aa81a936f1dc 100644
--- a/net/minecraft/world/level/material/LavaFluid.java
+++ b/net/minecraft/world/level/material/LavaFluid.java
@@ -172,7 +172,10 @@ public abstract class LavaFluid extends FlowingFluid {
@@ -184,7 +184,10 @@ public abstract class LavaFluid extends FlowingFluid {
@Override
public boolean canBeReplacedWith(FluidState fluidState, BlockGetter blockReader, BlockPos pos, Fluid fluid, Direction direction) {
@@ -1013,10 +1018,10 @@ index 3ee197e533460ef4fa87bebe18d02ffc76de8550..9b714ddad7208dd9509bf9f8434f1ace
@Override
diff --git a/net/minecraft/world/level/material/WaterFluid.java b/net/minecraft/world/level/material/WaterFluid.java
index 56781b47aeddf0c84d64ddf8b1aad7b26730b68c..6f478324e9edaf52f8938fb6e24208495463454f 100644
index 10e3c644e31650b0e1aad6349a83a763cf744ec8..62a51972df8edd1cc7f892376ba6e37eba1a301a 100644
--- a/net/minecraft/world/level/material/WaterFluid.java
+++ b/net/minecraft/world/level/material/WaterFluid.java
@@ -114,7 +114,12 @@ public abstract class WaterFluid extends FlowingFluid {
@@ -124,7 +124,12 @@ public abstract class WaterFluid extends FlowingFluid {
@Override
public boolean canBeReplacedWith(FluidState fluidState, BlockGetter blockReader, BlockPos pos, Fluid fluid, Direction direction) {

View File

@@ -5,15 +5,15 @@ Subject: [PATCH] Allow explosions to destroy lava
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index 8aa4debbc68530670ba6329554da5e9cf8e64a71..5d8d59fa34c9070d27e3ff38922eee465f03e663 100644
index 26cd9559013ca2bb17b98f2675e7c43f76519d8b..3e4580903b85cb4aa4a48a9882a641f03d8a440d 100644
--- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java
@@ -407,6 +407,11 @@ public class ServerExplosion implements Explosion {
@@ -404,6 +404,11 @@ public class ServerExplosion implements Explosion {
return Optional.of(ZERO_RESISTANCE);
}
// Sakura end - destroy water logged blocks
+ // Sakura start - allow explosions to destroy lava
+ if (blockState.is(Blocks.LAVA) && this.level.sakuraConfig().cannons.explosion.explodeLava) {
+ if (blockState.is(net.minecraft.world.level.block.Blocks.LAVA) && this.level.sakuraConfig().cannons.explosion.explodeLava) {
+ return Optional.of(ZERO_RESISTANCE);
+ }
+ // Sakura end - allow explosions to destroy lava
@@ -21,10 +21,10 @@ index 8aa4debbc68530670ba6329554da5e9cf8e64a71..5d8d59fa34c9070d27e3ff38922eee46
return this.damageCalculator.getBlockExplosionResistance(this, this.level, pos, blockState, fluidState);
diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java
index 5473b4006f7e0266ea11a7b05cef78a113c30d97..0a233c18fbad92c59b9c001574be3464f2be9d2c 100644
index 834e27ef2f7b342b074ff9e1e390e02f3ca1c399..fed11ed5ab97826915710b66395d1bdc926935b0 100644
--- a/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -204,7 +204,7 @@ public abstract class BlockBehaviour implements FeatureElement {
@@ -201,7 +201,7 @@ public abstract class BlockBehaviour implements FeatureElement {
state.getDrops(builder).forEach(stack -> dropConsumer.accept(stack, pos));
}

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Collide with non-solid blocks
diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
index 47c8ed946cb2ad81a4469daf60dabc40c5e8beda..16b66b19157081c7717f73ee3dc9111662a31922 100644
index 194db5ff2a473b10fded4491c1173d420f46424d..c09658eb8c2824ac0c887f94771d9b467ecab8b1 100644
--- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
+++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
@@ -1908,6 +1908,7 @@ public final class CollisionUtil {
@@ -34,8 +34,8 @@ index 47c8ed946cb2ad81a4469daf60dabc40c5e8beda..16b66b19157081c7717f73ee3dc91116
final PalettedContainer<BlockState> blocks = section.states;
@@ -2038,6 +2040,11 @@ public final class CollisionUtil {
if (useEntityCollisionShape) {
mutablePos.set(blockX, blockY, blockZ);
if (useEntityCollisionShape) {
blockCollision = collisionShape.getCollisionShape(blockData, world, mutablePos);
+ // Sakura start - collide with non-solid blocks
+ // todo: move this logic above emptyCollisionShape and consider all blocks as a solid except scaffolding and liquids
@@ -43,13 +43,13 @@ index 47c8ed946cb2ad81a4469daf60dabc40c5e8beda..16b66b19157081c7717f73ee3dc91116
+ blockCollision = net.minecraft.world.phys.shapes.Shapes.block();
+ // Sakura end - collide with non-solid blocks
} else if (blockCollision == null) {
mutablePos.set(blockX, blockY, blockZ);
blockCollision = blockData.getCollisionShape(world, mutablePos, collisionShape);
}
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index c74e20f1b20076e2eb289246f63d8363de2bc5e8..9a71820b766edd0b4d366735d96ae1241dba2047 100644
index 10c0bb5d1d88500e0002a726401a18313f5b3aaa..47ecc1ed0170e24b41b0a010307cc2bcab339a3a 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -538,6 +538,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -527,6 +527,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
flags |= ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_ADD_TICKET;
}

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Reduce entity tracker player updates
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
index e096463443639e9eef5311d7154f6d2ac1517883..4a5a6b6f163faa93c82e018eb9b6554486ea9ac7 100644
index 07d8bb89ed0f9cea6353905939ba9f91c6fb64a5..684af8df952b0e58a86f6c3b72635190fdc4a938 100644
--- a/net/minecraft/server/level/ChunkMap.java
+++ b/net/minecraft/server/level/ChunkMap.java
@@ -953,7 +953,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1015,7 +1015,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
if (tracker == null) {
continue;
}
@@ -21,7 +21,7 @@ index e096463443639e9eef5311d7154f6d2ac1517883..4a5a6b6f163faa93c82e018eb9b65544
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();
@@ -1197,12 +1201,30 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1259,12 +1263,30 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return state != me.samsuik.sakura.player.visibility.VisibilityState.OFF;
}
// Sakura end - client visibility settings; entity visibility
@@ -41,7 +41,7 @@ index e096463443639e9eef5311d7154f6d2ac1517883..4a5a6b6f163faa93c82e018eb9b65544
+ // Sakura start - reduce entity tracker player updates
public TrackedEntity(final Entity entity, final int range, final int updateInterval, final boolean trackDelta) {
this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this::broadcast, this.seenBy); // CraftBukkit
this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this::broadcast, this::broadcastIgnorePlayers, this.seenBy); // Paper
this.entity = entity;
this.range = range;
this.lastSectionPos = SectionPos.of(entity);

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Legacy lava block formation
diff --git a/net/minecraft/world/level/block/LiquidBlock.java b/net/minecraft/world/level/block/LiquidBlock.java
index b9b9f1a47cba3c72a306ec54896690701b76d34d..7dd5908068346efa7cd566657cc64d7ee42fc9eb 100644
index 1e8574d7900ffde16c2e1ee9f92a77c47c85af61..e9895a986dffd2ca170916b3e11f88bf36adae50 100644
--- a/net/minecraft/world/level/block/LiquidBlock.java
+++ b/net/minecraft/world/level/block/LiquidBlock.java
@@ -199,7 +199,14 @@ public class LiquidBlock extends Block implements BucketPickup {
@@ -25,10 +25,10 @@ index b9b9f1a47cba3c72a306ec54896690701b76d34d..7dd5908068346efa7cd566657cc64d7e
// SANITY: In legacy a patch by paper removes the fluid level condition from vanilla.
if (physics.before(1_16_0) && !physics.isLegacy() &&
diff --git a/net/minecraft/world/level/material/LavaFluid.java b/net/minecraft/world/level/material/LavaFluid.java
index 9b714ddad7208dd9509bf9f8434f1acea5a6f213..d073864e6d4be4e8001ff6e6a0a1dd92e95a9323 100644
index 34a40cf00c4337acd716358f7767aa81a936f1dc..ac052ccb2bfbd8a824b8f8d2ce8d55d8214b5fa9 100644
--- a/net/minecraft/world/level/material/LavaFluid.java
+++ b/net/minecraft/world/level/material/LavaFluid.java
@@ -174,7 +174,8 @@ public abstract class LavaFluid extends FlowingFluid {
@@ -186,7 +186,8 @@ public abstract class LavaFluid extends FlowingFluid {
public boolean canBeReplacedWith(FluidState fluidState, BlockGetter blockReader, BlockPos pos, Fluid fluid, Direction direction) {
// Sakura start - configure cannon physics
return fluidState.getHeight(blockReader, pos) >= 0.44444445F && fluid.is(FluidTags.WATER)
@@ -39,10 +39,10 @@ index 9b714ddad7208dd9509bf9f8434f1acea5a6f213..d073864e6d4be4e8001ff6e6a0a1dd92
}
diff --git a/net/minecraft/world/level/material/WaterFluid.java b/net/minecraft/world/level/material/WaterFluid.java
index 6f478324e9edaf52f8938fb6e24208495463454f..a1677a683dc530c0af5f2ead275cf57482860737 100644
index 62a51972df8edd1cc7f892376ba6e37eba1a301a..c8ebf065b250cc44fddd47c8622fb2110f2bfc0e 100644
--- a/net/minecraft/world/level/material/WaterFluid.java
+++ b/net/minecraft/world/level/material/WaterFluid.java
@@ -118,7 +118,10 @@ public abstract class WaterFluid extends FlowingFluid {
@@ -128,7 +128,10 @@ public abstract class WaterFluid extends FlowingFluid {
if (direction == Direction.DOWN && !fluid.is(FluidTags.WATER) || !(blockReader instanceof Level level)) {
return true;
}

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Add entity travel distance limits
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 512486514d2279c377b0fb6fd2a90b03c89d2209..0b575c9acf7e211bf62fde3bf9e82d6bdeb0f643 100644
index effdd0e1382fc59b9d8a709c18a652fbd4e94e6d..8f17606889b767539c19015ae7f1cb7795616b88 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -1296,6 +1296,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -1295,6 +1295,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
final boolean isActive = io.papermc.paper.entity.activation.ActivationRange.checkIfActive(entity); // Paper - EAR 2
if (isActive) { // Paper - EAR 2
entity.tick();
@@ -21,10 +21,10 @@ index 512486514d2279c377b0fb6fd2a90b03c89d2209..0b575c9acf7e211bf62fde3bf9e82d6b
} else {entity.inactiveTick();} // Paper - EAR 2
profilerFiller.pop();
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 15e54f3ddb12c392d4527661a2672a6856b14215..01c43ee5497037cb059255cc31d85f04dbfa78ed 100644
index 47ecc1ed0170e24b41b0a010307cc2bcab339a3a..06e919ddb07faa72721fd5660895abb3ad749dee 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -589,6 +589,19 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -581,6 +581,19 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return this.physics;
}
// Sakura end - configure cannon physics
@@ -36,15 +36,15 @@ index 15e54f3ddb12c392d4527661a2672a6856b14215..01c43ee5497037cb059255cc31d85f04
+ return false;
+ }
+
+ double x = Math.pow(this.origin.getX() - this.position.x(), 2);
+ double z = Math.pow(this.origin.getZ() - this.position.z(), 2);
+ double x = Math.pow(this.origin.x() - this.position.x(), 2);
+ double z = Math.pow(this.origin.z() - this.position.z(), 2);
+ return Math.max(x, z) >= this.travelDistanceLimit;
+ }
+ // Sakura end - entity travel distance limits
public Entity(EntityType<?> entityType, Level level) {
this.type = entityType;
@@ -618,6 +631,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -610,6 +623,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
this.setPos(0.0, 0.0, 0.0);
this.eyeHeight = this.dimensions.eyeHeight();
this.despawnTime = level == null || type == EntityType.PLAYER ? -1 : level.paperConfig().entities.spawning.despawnTime.getOrDefault(type, io.papermc.paper.configuration.type.number.IntOr.Disabled.DISABLED).or(-1); // Paper - entity despawn time limit

View File

@@ -5,16 +5,16 @@ Subject: [PATCH] Protect scaffolding from creepers
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index 5d8d59fa34c9070d27e3ff38922eee465f03e663..95fecb0338bc9c7b6c2ca484994f2f72370c5822 100644
index 3e4580903b85cb4aa4a48a9882a641f03d8a440d..9a3cf92fd767559484d3bd9f94e1c13facbfa86f 100644
--- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java
@@ -412,6 +412,11 @@ public class ServerExplosion implements Explosion {
@@ -409,6 +409,11 @@ public class ServerExplosion implements Explosion {
return Optional.of(ZERO_RESISTANCE);
}
// Sakura end - allow explosions to destroy lava
+ // Sakura start - protect scaffolding from creepers
+ if (this.level.sakuraConfig().cannons.explosion.protectScaffoldingFromCreepers && blockState.is(Blocks.SCAFFOLDING) && this.source instanceof net.minecraft.world.entity.monster.Creeper) {
+ return Optional.of(Blocks.BARRIER.getExplosionResistance());
+ if (this.level.sakuraConfig().cannons.explosion.protectScaffoldingFromCreepers && blockState.is(net.minecraft.world.level.block.Blocks.SCAFFOLDING) && this.source instanceof net.minecraft.world.entity.monster.Creeper) {
+ return Optional.of(net.minecraft.world.level.block.Blocks.BARRIER.getExplosionResistance());
+ }
+ // Sakura end - protect scaffolding from creepers
}

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Configurable left shooting and adjusting limits
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index b10b375a8ede214b0dd0615cb5625cd45e27b20e..2dbf517562eb2f49d426697faaf02a126d7c6b0d 100644
index 06e919ddb07faa72721fd5660895abb3ad749dee..f02b6dbdfaadbbbe3d4328b77fbd29cf26406946 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -602,6 +602,46 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -594,6 +594,46 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return Math.max(x, z) >= this.travelDistanceLimit;
}
// Sakura end - entity travel distance limits
@@ -17,8 +17,8 @@ index b10b375a8ede214b0dd0615cb5625cd45e27b20e..2dbf517562eb2f49d426697faaf02a12
+ Vec3 movement = this.getDeltaMovement();
+ int threshold = this.level.sakuraConfig().cannons.restrictions.leftShootingThreshold.or(-1);
+ if (threshold > 0 && (movement.x != 0.0 || movement.z != 0.0) && this.origin != null) {
+ double travelledX = Math.abs(this.getX() - this.origin.getX());
+ double travelledZ = Math.abs(this.getZ() - this.origin.getZ());
+ double travelledX = Math.abs(this.getX() - this.origin.x());
+ double travelledZ = Math.abs(this.getZ() - this.origin.z());
+ boolean xSmaller = travelledX < travelledZ; // intended
+
+ // Once entities have travelled past the threshold changing direction is restricted.
@@ -55,7 +55,7 @@ index b10b375a8ede214b0dd0615cb5625cd45e27b20e..2dbf517562eb2f49d426697faaf02a12
public Entity(EntityType<?> entityType, Level level) {
this.type = entityType;
@@ -1573,6 +1613,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -1596,6 +1636,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
}
if (xSmaller && z != 0.0) {
@@ -63,7 +63,7 @@ index b10b375a8ede214b0dd0615cb5625cd45e27b20e..2dbf517562eb2f49d426697faaf02a12
z = this.scanZ(currBoundingBox, z, voxelList, bbList);
if (z != 0.0) {
currBoundingBox = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.offsetZ(currBoundingBox, z);
@@ -1580,6 +1621,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -1603,6 +1644,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
}
if (x != 0.0) {
@@ -76,7 +76,7 @@ index b10b375a8ede214b0dd0615cb5625cd45e27b20e..2dbf517562eb2f49d426697faaf02a12
if (x != 0.0) {
currBoundingBox = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.offsetX(currBoundingBox, x);
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
index e4e708609799799ed2e7dd516ba8bf61e98bc022..5b7fb6a1c39121bbfc7ef6631aea741f9bd0e244 100644
index 029ef84a62683fa75b4222a11d09925f54d2fd55..c1884ba86be8da92c7f0168315c590eb6d7bf966 100644
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -284,6 +284,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Optimise hopper ticking
diff --git a/net/minecraft/world/CompoundContainer.java b/net/minecraft/world/CompoundContainer.java
index 82923c9db0c620fe83c4d4447e6eb0dd8a6bb334..0dbc419884bd407dcbd44f7f0aef89754526a18f 100644
index 0e9beb7f74e527a95bff064631e6d591f5775ce5..f89a8a3a1f3c87432c8816c3273c7b25b324055b 100644
--- a/net/minecraft/world/CompoundContainer.java
+++ b/net/minecraft/world/CompoundContainer.java
@@ -48,6 +48,15 @@ public class CompoundContainer implements Container {
@@ -53,6 +53,15 @@ public class CompoundContainer implements Container {
return this.container1.getLocation(); // TODO: right?
}
// CraftBukkit end
@@ -25,11 +25,11 @@ index 82923c9db0c620fe83c4d4447e6eb0dd8a6bb334..0dbc419884bd407dcbd44f7f0aef8975
public CompoundContainer(Container container1, Container container2) {
this.container1 = container1;
diff --git a/net/minecraft/world/Container.java b/net/minecraft/world/Container.java
index 2d3721e311851c1801b090e99d4f9d0daf4e5f99..2249f5338f97471a833acddcee95f6a769176ce8 100644
index b382665cc125b8b5c0938e5e55984e4bf91d37ff..0c4358053076416fc2cd3f5c9b7f6d2f630cab10 100644
--- a/net/minecraft/world/Container.java
+++ b/net/minecraft/world/Container.java
@@ -12,6 +12,12 @@ import net.minecraft.world.level.block.entity.BlockEntity;
public interface Container extends Clearable {
@@ -14,6 +14,12 @@ import net.minecraft.world.level.block.entity.BlockEntity;
public interface Container extends Clearable, Iterable<ItemStack> {
float DEFAULT_DISTANCE_BUFFER = 4.0F;
+ // Sakura start - optimise hopper ticking
@@ -42,10 +42,10 @@ index 2d3721e311851c1801b090e99d4f9d0daf4e5f99..2249f5338f97471a833acddcee95f6a7
boolean isEmpty();
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index f7a341082d78667d34e7832f4567bbf4f3f86a00..850de480eb3408b3a4468266aa7d16a09332b237 100644
index 769887ee6d798d0b11de72e9ffe80c9d358daf17..701a48ba3b0f4515a791684d63b3454dbed317f9 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -1499,7 +1499,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -1483,7 +1483,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
// Spigot end
if (tickingBlockEntity.isRemoved()) {
toRemove.add(tickingBlockEntity); // Paper - Fix MC-117075; use removeAll
@@ -55,10 +55,10 @@ index f7a341082d78667d34e7832f4567bbf4f3f86a00..850de480eb3408b3a4468266aa7d16a0
// Paper start - rewrite chunk system
if ((++tickedEntities & 7) == 0) {
diff --git a/net/minecraft/world/level/block/HopperBlock.java b/net/minecraft/world/level/block/HopperBlock.java
index 8ce44400279511f78a0773a23a2aafc3f887ade3..1457d9feee282e375a56b19423cc6fb561521d13 100644
index 46a27f60ba407dacdac190b5e292ab3f1db5a078..ec05bb86803d878867b46e437cc73a39f155b9fc 100644
--- a/net/minecraft/world/level/block/HopperBlock.java
+++ b/net/minecraft/world/level/block/HopperBlock.java
@@ -140,6 +140,12 @@ public class HopperBlock extends BaseEntityBlock {
@@ -121,6 +121,12 @@ public class HopperBlock extends BaseEntityBlock {
private void checkPoweredState(Level level, BlockPos pos, BlockState state) {
boolean flag = !level.hasNeighborSignal(pos);
if (flag != state.getValue(ENABLED)) {
@@ -68,14 +68,14 @@ index 8ce44400279511f78a0773a23a2aafc3f887ade3..1457d9feee282e375a56b19423cc6fb5
+ hbe.setBlockEntityTicking(flag);
+ }
+ // Sakura end - optimise hopper ticking
level.setBlock(pos, state.setValue(ENABLED, Boolean.valueOf(flag)), 2);
level.setBlock(pos, state.setValue(ENABLED, flag), 2);
}
}
diff --git a/net/minecraft/world/level/block/entity/BlockEntity.java b/net/minecraft/world/level/block/entity/BlockEntity.java
index 77618757c0e678532dbab814aceed83f7f1cd892..9b20f66af27331b00c1985b1e21804eb6eb419de 100644
index a1075c26d55cc01219acd94d0138f81aa9d34c48..6aa0624eb99223dc13478a24f74a49654019fba5 100644
--- a/net/minecraft/world/level/block/entity/BlockEntity.java
+++ b/net/minecraft/world/level/block/entity/BlockEntity.java
@@ -40,6 +40,60 @@ public abstract class BlockEntity {
@@ -48,6 +48,60 @@ public abstract class BlockEntity {
private BlockState blockState;
private DataComponentMap components = DataComponentMap.EMPTY;
@@ -136,7 +136,7 @@ index 77618757c0e678532dbab814aceed83f7f1cd892..9b20f66af27331b00c1985b1e21804eb
public BlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState blockState) {
this.type = type;
this.worldPosition = pos.immutable();
@@ -198,11 +252,22 @@ public abstract class BlockEntity {
@@ -204,11 +258,22 @@ public abstract class BlockEntity {
public void setChanged() {
if (this.level != null) {
if (ignoreBlockEntityUpdates) return; // Paper - Perf: Optimize Hoppers
@@ -160,7 +160,7 @@ index 77618757c0e678532dbab814aceed83f7f1cd892..9b20f66af27331b00c1985b1e21804eb
level.blockEntityChanged(pos);
if (!state.isAir()) {
level.updateNeighbourForOutputSignal(pos, state.getBlock());
@@ -232,6 +297,7 @@ public abstract class BlockEntity {
@@ -238,6 +303,7 @@ public abstract class BlockEntity {
public void setRemoved() {
this.remove = true;
@@ -169,7 +169,7 @@ index 77618757c0e678532dbab814aceed83f7f1cd892..9b20f66af27331b00c1985b1e21804eb
public void clearRemoved() {
diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
index 5cd1326ad5d046c88b2b3449d610a78fa880b4cd..c5e7040367d7d652e4298a4f8f8e589a2c11183f 100644
index 15d4f60942c0cc612c1468b4c0fda886867a67cb..98856a692b3ae5ac46cb67678642709b4f931ee7 100644
--- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
@@ -28,7 +28,7 @@ import net.minecraft.world.level.block.HopperBlock;
@@ -181,7 +181,7 @@ index 5cd1326ad5d046c88b2b3449d610a78fa880b4cd..c5e7040367d7d652e4298a4f8f8e589a
public static final int MOVE_ITEM_SPEED = 8;
public static final int HOPPER_CONTAINER_SIZE = 5;
private static final int[][] CACHED_SLOTS = new int[54][];
@@ -66,6 +66,58 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -71,6 +71,58 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
this.maxStack = size;
}
// CraftBukkit end
@@ -238,9 +238,9 @@ index 5cd1326ad5d046c88b2b3449d610a78fa880b4cd..c5e7040367d7d652e4298a4f8f8e589a
+ }
+ // Sakura end - optimise hopper ticking
public HopperBlockEntity(BlockPos pos, BlockState blockState) {
@@ -196,6 +248,12 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
super(BlockEntityType.HOPPER, pos, blockState);
@@ -200,6 +252,12 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
setChanged(level, pos, state);
return true;
}
@@ -253,7 +253,7 @@ index 5cd1326ad5d046c88b2b3449d610a78fa880b4cd..c5e7040367d7d652e4298a4f8f8e589a
}
return false;
@@ -413,7 +471,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -417,7 +475,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
// Paper end - Perf: Optimize Hoppers
private static boolean ejectItems(Level level, BlockPos pos, HopperBlockEntity blockEntity) {
@@ -262,7 +262,7 @@ index 5cd1326ad5d046c88b2b3449d610a78fa880b4cd..c5e7040367d7d652e4298a4f8f8e589a
if (attachedContainer == null) {
return false;
} else {
@@ -526,7 +584,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -530,7 +588,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
public static boolean suckInItems(Level level, Hopper hopper) {
BlockPos blockPos = BlockPos.containing(hopper.getLevelX(), hopper.getLevelY() + 1.0, hopper.getLevelZ());
BlockState blockState = level.getBlockState(blockPos);
@@ -287,10 +287,10 @@ index 28e3b73507b988f7234cbf29c4024c88180d0aef..a0d247aa883553708c4b921582324255
+ // Sakura end - optimise hopper ticking
}
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
index f8b5c74403ebf936bbac20d68a2dfa7b0aca9cfc..b9391bae49ee0b3997ea2dfa19e82624ba1595f0 100644
index cfc125d43cf3702d46c221f4e7b0d66a15c5d690..9f1a944b82051ea957a0fe725ca95b8f26491f1d 100644
--- a/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
@@ -976,6 +976,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
@@ -980,6 +980,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
return BlockEntityType.getKey(this.blockEntity.getType()).toString();
}
@@ -304,7 +304,7 @@ index f8b5c74403ebf936bbac20d68a2dfa7b0aca9cfc..b9391bae49ee0b3997ea2dfa19e82624
@Override
public String toString() {
return "Level ticker for " + this.getType() + "@" + this.getPos();
@@ -1024,6 +1031,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
@@ -1028,6 +1035,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
return this.ticker.getType();
}

View File

@@ -48,10 +48,10 @@ index 26207443b1223119c03db478d7e816d9cdf8e618..1664830a49f37825c39fb6b436011d81
@Override
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index 259c2b2d459d86cb11ab848c77f48c38ed174a63..fad4aabc0ff3f484e271c4784543cdf2c3c2cafd 100644
index b234215e59ac303ef7979031ab1b042ff6692b7a..4898079bb4cceeb1106e1eac08f92417bdb2daf7 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -1678,7 +1678,17 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1676,7 +1676,17 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
// Paper start - Folia scheduler API
((io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler) org.bukkit.Bukkit.getGlobalRegionScheduler()).tick();
getAllLevels().forEach(level -> {

View File

@@ -0,0 +1,77 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
Date: Fri, 8 Nov 2024 19:35:49 +0000
Subject: [PATCH] Optimise check inside blocks and traverse blocks
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index f02b6dbdfaadbbbe3d4328b77fbd29cf26406946..bb7b919f3005deeb1cde5748bd3987ccba59c16b 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -1876,6 +1876,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
private void checkInsideBlocks(List<Entity.Movement> movements, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector) {
if (this.isAffectedByBlocks()) {
LongSet set = this.visitedBlocks;
+ final net.minecraft.world.level.chunk.ChunkAccess[] chunkCache = new net.minecraft.world.level.chunk.ChunkAccess[4]; // Sakura - optimise check inside blocks
for (Entity.Movement movement : movements) {
Vec3 vec3 = movement.from();
@@ -1891,7 +1892,20 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
this.physics, // Sakura - configure cannon physics
(pos, step) -> {
if (this.isAlive()) {
- BlockState blockState = this.level().getBlockState(pos);
+ // Sakura start - optimise check inside blocks
+ final int chunkX = pos.getX() >> 4;
+ final int chunkZ = pos.getZ() >> 4;
+ final int chunkKey = ((chunkX << 2) | chunkZ) & 3;
+ net.minecraft.world.level.chunk.ChunkAccess chunk = chunkCache[chunkKey];
+ if (chunk == null || chunk.locX != chunkX || chunk.locZ != chunkZ) {
+ chunk = this.level().getChunkIfLoadedImmediately(chunkX, chunkZ);
+ if (chunk == null) {
+ return;
+ }
+ chunkCache[chunkKey] = chunk;
+ }
+ final BlockState blockState = chunk.getBlockState(pos);
+ // Sakura end - optimise check inside blocks
if (!blockState.isAir()) {
if (set.add(pos.asLong())) {
VoxelShape entityInsideCollisionShape = blockState.getEntityInsideCollisionShape(this.level(), pos, this);
diff --git a/net/minecraft/world/level/BlockGetter.java b/net/minecraft/world/level/BlockGetter.java
index 673e07e24c0cc0bc8301a15ca028c0bd72a3439c..11f9181e5c829cff7adf4feef9a6e6942b021850 100644
--- a/net/minecraft/world/level/BlockGetter.java
+++ b/net/minecraft/world/level/BlockGetter.java
@@ -221,18 +221,30 @@ public interface BlockGetter extends LevelHeightAccessor {
Vec3 vec3 = to.subtract(from);
if ((physics == null || physics.afterOrEqual(1_21_2)) && !(vec3.lengthSqr() < Mth.square(0.99999F))) {
// Sakura end - configure cannon physics
+ // Sakura start - optimise check inside blocks
+ final boolean xZero = vec3.x() == 0.0;
+ final boolean yZero = vec3.y() == 0.0;
+ final boolean zZero = vec3.z() == 0.0;
+ if (xZero && yZero || yZero && zZero || xZero && zZero) {
+ int blockIndex = 0;
+ for (BlockPos blockPos : me.samsuik.sakura.utils.BlockPosIterator.traverseArea(vec3, boundingBox)) {
+ stepVisitor.visit(blockPos, blockIndex++);
+ }
+ return;
+ }
+ // Sakura end - optimise check inside blocks
LongSet set = new LongOpenHashSet();
Vec3 minPosition = boundingBox.getMinPosition();
Vec3 vec31 = minPosition.subtract(vec3);
int i = addCollisionsAlongTravel(set, vec31, minPosition, boundingBox, stepVisitor);
- for (BlockPos blockPos1 : BlockPos.betweenClosed(boundingBox)) {
+ for (BlockPos blockPos1 : me.samsuik.sakura.utils.BlockPosIterator.iterable(boundingBox)) { // Sakura - optimise check inside blocks
if (!set.contains(blockPos1.asLong())) {
stepVisitor.visit(blockPos1, i + 1);
}
}
} else {
- for (BlockPos blockPos : BlockPos.betweenClosed(boundingBox)) {
+ for (BlockPos blockPos : me.samsuik.sakura.utils.BlockPosIterator.iterable(boundingBox)) { // Sakura - optimise check inside blocks
stepVisitor.visit(blockPos, 0);
}
}

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] copy EntityList implementation to BasicEntityList
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
index a242b68b6d603d3da46d9e0635a86a07a7149b3b..2cf9c56d234b32a1ae95bdde73fd5f6aaa2ca82c 100644
index 417afe621f559d7fab0798ccf586b630e8878b23..512a3b2d09d90e07158684995477d79dff3821b5 100644
--- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
@@ -396,6 +396,13 @@ public final class ChunkEntitySlices {

View File

@@ -33,10 +33,10 @@ index ff747a1ecdf3c888bca0d69de4f85dcd810b6139..d90f6aa4557b5863eba6a206226f763c
}
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 539c2e465d4c89584b5bccaad18fadc41db0643a..ca21ac80c07f6aeecf01791d0eb7b5236063a0ed 100644
index 8f17606889b767539c19015ae7f1cb7795616b88..529c412890993600d52287e0446757d1598bb45a 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -699,6 +699,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -689,6 +689,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
this.levelTickScheduler.registerNewTask(this.explosionPositions::clear, 0); // Sakura - client visibility settings
this.levelTickScheduler.registerNewTask(this.mergeHandler::expire, 200); // Sakura - merge cannon entities
this.levelTickScheduler.registerNewTask(this.densityCache::invalidate, 0); // Sakura - explosion density cache
@@ -45,10 +45,10 @@ index 539c2e465d4c89584b5bccaad18fadc41db0643a..ca21ac80c07f6aeecf01791d0eb7b523
// Paper start
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 850de480eb3408b3a4468266aa7d16a09332b237..56161f32e9fb379fc207b0ef2c1ba44e9516b32f 100644
index 701a48ba3b0f4515a791684d63b3454dbed317f9..8156e920d76a92fd74b90de816aaff0ced480b5f 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -844,6 +844,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -831,6 +831,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
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
@@ -57,10 +57,10 @@ index 850de480eb3408b3a4468266aa7d16a09332b237..56161f32e9fb379fc207b0ef2c1ba44e
protected Level(
WritableLevelData levelData,
diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java
index 31a76dc1ee4a02ad91637b27d1927b5a5d38ddb3..f1f6159fd097db461032b8bcfdaa8bc761fbf341 100644
index 270c405a7384e3290b4eea58e0b231aa6235d85a..a1428aab6923a58c04d206d63babd93242ed1ff9 100644
--- a/net/minecraft/world/level/block/RedStoneWireBlock.java
+++ b/net/minecraft/world/level/block/RedStoneWireBlock.java
@@ -331,6 +331,12 @@ public class RedStoneWireBlock extends Block {
@@ -306,6 +306,12 @@ public class RedStoneWireBlock extends Block {
newPower = event.getNewCurrent();
@@ -73,7 +73,7 @@ index 31a76dc1ee4a02ad91637b27d1927b5a5d38ddb3..f1f6159fd097db461032b8bcfdaa8bc7
if (level.getBlockState(pos) == state) {
state = state.setValue(POWER, newPower);
// [Space Walker] suppress shape updates and emit those manually to
@@ -338,6 +344,7 @@ public class RedStoneWireBlock extends Block {
@@ -313,6 +319,7 @@ public class RedStoneWireBlock extends Block {
if (level.setBlock(pos, state, Block.UPDATE_KNOWN_SHAPE | Block.UPDATE_CLIENTS)) {
turbo.updateNeighborShapes(level, pos, state);
}
@@ -81,7 +81,7 @@ index 31a76dc1ee4a02ad91637b27d1927b5a5d38ddb3..f1f6159fd097db461032b8bcfdaa8bc7
}
}
return state;
@@ -460,8 +467,14 @@ public class RedStoneWireBlock extends Block {
@@ -432,8 +439,14 @@ public class RedStoneWireBlock extends Block {
if (powerValue == 0) {
return 0;
} else {
@@ -99,10 +99,10 @@ index 31a76dc1ee4a02ad91637b27d1927b5a5d38ddb3..f1f6159fd097db461032b8bcfdaa8bc7
: powerValue;
}
diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java
index 0a233c18fbad92c59b9c001574be3464f2be9d2c..80db5829a8b023ffbc25341168466a398346e1b8 100644
index fed11ed5ab97826915710b66395d1bdc926935b0..d6131c5ec6a4229291f7cecb9cec9251d54244ed 100644
--- a/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -524,6 +524,13 @@ public abstract class BlockBehaviour implements FeatureElement {
@@ -521,6 +521,13 @@ public abstract class BlockBehaviour implements FeatureElement {
return this.constantCollisionShape;
}
// Paper end - optimise collisions
@@ -116,7 +116,7 @@ index 0a233c18fbad92c59b9c001574be3464f2be9d2c..80db5829a8b023ffbc25341168466a39
protected BlockStateBase(Block owner, Reference2ObjectArrayMap<Property<?>, Comparable<?>> values, MapCodec<BlockState> propertiesCodec) {
super(owner, values, propertiesCodec);
@@ -638,6 +645,7 @@ public abstract class BlockBehaviour implements FeatureElement {
@@ -635,6 +642,7 @@ public abstract class BlockBehaviour implements FeatureElement {
}
}
// Paper end - optimise collisions
@@ -151,7 +151,7 @@ index 028eae2f9a459b60e92f3344091083aa93b54485..9fbf679b54088f89ac4ba727ccb645d6
this.addedThisLayer.clear();
this.count = 0;
diff --git a/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java b/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
index 2d77780b6727f82ffc3cb216ca5f2d6483496cfd..981ec4e417d07a475a19032b0efe2e188e2e7180 100644
index abcc144a086a45bf4cfa4d1a33e2ae10952e0da2..3fc901aa038e65e3e219b92d0fa37e5dd620926f 100644
--- a/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
+++ b/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
@@ -27,7 +27,14 @@ public class DefaultRedstoneWireEvaluator extends RedstoneWireEvaluator {
@@ -166,7 +166,7 @@ index 2d77780b6727f82ffc3cb216ca5f2d6483496cfd..981ec4e417d07a475a19032b0efe2e18
if (level.getBlockState(pos) == state) {
+ wireCache.trackWirePower(pos, i, oldPower);
+ // Sakura end - cache vanilla and eigencraft wires
level.setBlock(pos, state.setValue(RedStoneWireBlock.POWER, Integer.valueOf(i)), 2);
level.setBlock(pos, state.setValue(RedStoneWireBlock.POWER, i), 2);
}
@@ -39,6 +46,7 @@ public class DefaultRedstoneWireEvaluator extends RedstoneWireEvaluator {
@@ -178,7 +178,7 @@ index 2d77780b6727f82ffc3cb216ca5f2d6483496cfd..981ec4e417d07a475a19032b0efe2e18
}
}
diff --git a/net/minecraft/world/level/redstone/NeighborUpdater.java b/net/minecraft/world/level/redstone/NeighborUpdater.java
index 26c15c60d358273a3b369c286771c81d6f0979dd..485a5a5df6f94ea9793cc4ac8141679fa8527532 100644
index 332b33a004ab11150cca0cc2cefc26d0286648f5..3691a8b2306ad4fb555ea3b4cefb8e1ea0c14b6b 100644
--- a/net/minecraft/world/level/redstone/NeighborUpdater.java
+++ b/net/minecraft/world/level/redstone/NeighborUpdater.java
@@ -17,6 +17,12 @@ import net.minecraft.world.level.block.state.BlockState;

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Configure breaking blocks outside the world border
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index 451cb54da29ad7e6fc74f4a57df8493ce3e43b2d..71401708e65c9b06f30d124757fecf5f61eff957 100644
index 9a3cf92fd767559484d3bd9f94e1c13facbfa86f..05d288c0f467ca28d28afa944c5ec41952085ec9 100644
--- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java
@@ -538,6 +538,11 @@ public class ServerExplosion implements Explosion {
@@ -535,6 +535,11 @@ public class ServerExplosion implements Explosion {
return ret;
}
// Sakura end - optimise protected explosions

View File

@@ -24,9 +24,9 @@
+ }
+ // Sakura end - track tick information
public MinecraftServer(
// CraftBukkit start
@@ -398,6 +_,10 @@
// Paper start - rewrite chunk system
private volatile Throwable chunkSystemCrash;
@@ -469,6 +_,10 @@
Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
// CraftBukkit end
this.paperConfigurations = services.paperConfigurations(); // Paper - add paper configuration files
@@ -37,7 +37,7 @@
}
private void readScoreboard(DimensionDataStorage dataStorage) {
@@ -1139,6 +_,7 @@
@@ -1219,6 +_,7 @@
if (++MinecraftServer.currentTick % MinecraftServer.SAMPLE_INTERVAL == 0) {
final long diff = currentTime - tickSection;
final java.math.BigDecimal currentTps = TPS_BASE.divide(new java.math.BigDecimal(diff), 30, java.math.RoundingMode.HALF_UP);
@@ -45,11 +45,11 @@
tps1.add(currentTps, diff);
tps5.add(currentTps, diff);
tps15.add(currentTps, diff);
@@ -1167,6 +_,7 @@
profilerFiller.push("tick");
this.tickFrame.start();
this.tickServer(flag ? () -> false : this::haveTime);
+ this.tickInformationCollector.tickDuration((System.nanoTime() - currentTime) / 1_000_000L); // Sakura - track tick information
@@ -1256,6 +_,7 @@
// Paper end - rewrite chunk system
this.tickFrame.end();
profilerFiller.popPush("nextTickWait");
+ this.tickInformationCollector.tickDuration((System.nanoTime() - currentTime) / 1_000_000L); // Sakura - track tick information
this.mayHaveDelayedTasks = true;
this.delayedTasksMaxNextTickTimeNanos = Math.max(Util.getNanos() + l, this.nextTickTimeNanos);
this.startMeasuringTaskExecutionTime();

View File

@@ -1,15 +1,15 @@
--- a/net/minecraft/server/level/ChunkMap.java
+++ b/net/minecraft/server/level/ChunkMap.java
@@ -138,7 +_,7 @@
private final AtomicInteger tickingGenerated = new AtomicInteger();
@@ -134,7 +_,7 @@
public final AtomicInteger tickingGenerated = new AtomicInteger(); // Paper - public
private final String storageName;
private final PlayerMap playerMap = new PlayerMap();
- public final Int2ObjectMap<ChunkMap.TrackedEntity> entityMap = new Int2ObjectOpenHashMap<>();
+ public final Int2ObjectMap<ChunkMap.TrackedEntity> entityMap = new me.samsuik.sakura.utils.collections.TrackedEntityChunkMap(); // Sakura - optimised tracked entity map
private final Long2ByteMap chunkTypeCache = new Long2ByteOpenHashMap();
private final Long2LongMap nextChunkSaveTime = new Long2LongOpenHashMap();
private final LongSet chunksToEagerlySave = new LongLinkedOpenHashSet();
@@ -1420,7 +_,10 @@
// Paper - rewrite chunk system
public int serverViewDistance;
@@ -1287,7 +_,10 @@
double vec3_dz = player.getZ() - this.entity.getZ();
// Paper end - remove allocation of Vec3D here
int playerViewDistance = ChunkMap.this.getPlayerViewDistance(player);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -343,7 +_,7 @@
@@ -580,7 +_,7 @@
org.bukkit.generator.BiomeProvider biomeProvider // CraftBukkit
) {
// CraftBukkit start

View File

@@ -1,10 +1,10 @@
--- a/net/minecraft/server/level/ServerPlayer.java
+++ b/net/minecraft/server/level/ServerPlayer.java
@@ -422,6 +_,7 @@
@@ -428,6 +_,7 @@
public @Nullable com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent
public @Nullable String clientBrandName = null; // Paper - Brand support
public @Nullable org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event
+ public double trackingRangeModifier = 1.0; // Sakura - entity tracking range modifier
public ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) {
super(level, level.getSharedSpawnPos(), level.getSharedSpawnAngle(), gameProfile);
// Paper start - rewrite chunk system
private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader;

View File

@@ -1,14 +1,14 @@
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -405,6 +_,7 @@
return this.dimensions.makeBoundingBox(x, y, z);
@@ -511,6 +_,7 @@
}
// Paper end
}
// Paper end - optimise entity tracker
+ public boolean pushedByFluid = true; // Sakura - entity pushed by fluid api
public Entity(EntityType<?> entityType, Level level) {
this.type = entityType;
@@ -3749,7 +_,7 @@
@@ -3986,7 +_,7 @@
}
public boolean isPushedByFluid() {

View File

@@ -10,7 +10,7 @@
+ // Sakura start - configure potion mechanics
+ final AABB movementAABB = projectile.getBoundingBox().expandTowards(deltaMovement).inflate(1.0);
+ final HitResult entityHitResult;
+ if (level.sakuraConfig().entity.thrownPotion.allowBreakingInsideEntities && projectile instanceof ThrownPotion) {
+ if (level.sakuraConfig().entity.thrownPotion.allowBreakingInsideEntities && projectile instanceof AbstractThrownPotion) {
+ entityHitResult = getEntityHitResult(projectile, pos, vec3, movementAABB, filter, margin);
+ } else {
+ entityHitResult = getEntityHitResult(level, projectile, pos, vec3, movementAABB, filter, margin);

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/item/ItemStack.java
+++ b/net/minecraft/world/item/ItemStack.java
@@ -831,6 +_,15 @@
return this.getItem().interactLivingEntity(this, player, entity, usedHand);
@@ -847,6 +_,15 @@
}
}
+ // Sakura start - modify components sent to the client
@@ -13,6 +13,6 @@
+ }
+ // Sakura end - modify components sent to the client
+
public ItemStack copy() {
public ItemStack copyWithCount(int count) {
if (this.isEmpty()) {
return EMPTY;

View File

@@ -5,37 +5,37 @@
public static final Item NETHERITE_INGOT = registerItem("netherite_ingot", new Item.Properties().fireResistant().trimMaterial(TrimMaterials.NETHERITE));
public static final Item NETHERITE_SCRAP = registerItem("netherite_scrap", new Item.Properties().fireResistant());
- public static final Item WOODEN_SWORD = registerItem("wooden_sword", new Item.Properties().sword(ToolMaterial.WOOD, 3.0F, -2.4F));
+ public static final Item WOODEN_SWORD = registerItem("wooden_sword", properties -> new me.samsuik.sakura.player.item.BlockableSwordItem(new Item.Properties().sword(ToolMaterial.WOOD, 3.0F, -2.4F))); // Sakura - allow blocking with swords
+ public static final Item WOODEN_SWORD = registerItem("wooden_sword", me.samsuik.sakura.player.item.BlockableSwordItem::new, new Item.Properties().sword(ToolMaterial.WOOD, 3.0F, -2.4F)); // Sakura - allow blocking with swords
public static final Item WOODEN_SHOVEL = registerItem("wooden_shovel", properties -> new ShovelItem(ToolMaterial.WOOD, 1.5F, -3.0F, properties));
public static final Item WOODEN_PICKAXE = registerItem("wooden_pickaxe", new Item.Properties().pickaxe(ToolMaterial.WOOD, 1.0F, -2.8F));
public static final Item WOODEN_AXE = registerItem("wooden_axe", properties -> new AxeItem(ToolMaterial.WOOD, 6.0F, -3.2F, properties));
public static final Item WOODEN_HOE = registerItem("wooden_hoe", properties -> new HoeItem(ToolMaterial.WOOD, 0.0F, -3.0F, properties));
- public static final Item STONE_SWORD = registerItem("stone_sword", new Item.Properties().sword(ToolMaterial.STONE, 3.0F, -2.4F));
+ public static final Item STONE_SWORD = registerItem("stone_sword", properties -> new me.samsuik.sakura.player.item.BlockableSwordItem(new Item.Properties().sword(ToolMaterial.STONE, 3.0F, -2.4F))); // Sakura - allow blocking with swords
+ public static final Item STONE_SWORD = registerItem("stone_sword", me.samsuik.sakura.player.item.BlockableSwordItem::new, new Item.Properties().sword(ToolMaterial.STONE, 3.0F, -2.4F)); // Sakura - allow blocking with swords
public static final Item STONE_SHOVEL = registerItem("stone_shovel", properties -> new ShovelItem(ToolMaterial.STONE, 1.5F, -3.0F, properties));
public static final Item STONE_PICKAXE = registerItem("stone_pickaxe", new Item.Properties().pickaxe(ToolMaterial.STONE, 1.0F, -2.8F));
public static final Item STONE_AXE = registerItem("stone_axe", properties -> new AxeItem(ToolMaterial.STONE, 7.0F, -3.2F, properties));
public static final Item STONE_HOE = registerItem("stone_hoe", properties -> new HoeItem(ToolMaterial.STONE, -1.0F, -2.0F, properties));
- public static final Item GOLDEN_SWORD = registerItem("golden_sword", new Item.Properties().sword(ToolMaterial.GOLD, 3.0F, -2.4F));
+ public static final Item GOLDEN_SWORD = registerItem("golden_sword", properties -> new me.samsuik.sakura.player.item.BlockableSwordItem(new Item.Properties().sword(ToolMaterial.GOLD, 3.0F, -2.4F))); // Sakura - allow blocking with swords
+ public static final Item GOLDEN_SWORD = registerItem("golden_sword", me.samsuik.sakura.player.item.BlockableSwordItem::new, new Item.Properties().sword(ToolMaterial.GOLD, 3.0F, -2.4F)); // Sakura - allow blocking with swords
public static final Item GOLDEN_SHOVEL = registerItem("golden_shovel", properties -> new ShovelItem(ToolMaterial.GOLD, 1.5F, -3.0F, properties));
public static final Item GOLDEN_PICKAXE = registerItem("golden_pickaxe", new Item.Properties().pickaxe(ToolMaterial.GOLD, 1.0F, -2.8F));
public static final Item GOLDEN_AXE = registerItem("golden_axe", properties -> new AxeItem(ToolMaterial.GOLD, 6.0F, -3.0F, properties));
public static final Item GOLDEN_HOE = registerItem("golden_hoe", properties -> new HoeItem(ToolMaterial.GOLD, 0.0F, -3.0F, properties));
- public static final Item IRON_SWORD = registerItem("iron_sword", new Item.Properties().sword(ToolMaterial.IRON, 3.0F, -2.4F));
+ public static final Item IRON_SWORD = registerItem("iron_sword", properties -> new me.samsuik.sakura.player.item.BlockableSwordItem(new Item.Properties().sword(ToolMaterial.IRON, 3.0F, -2.4F))); // Sakura - allow blocking with swords
+ public static final Item IRON_SWORD = registerItem("iron_sword", me.samsuik.sakura.player.item.BlockableSwordItem::new, new Item.Properties().sword(ToolMaterial.IRON, 3.0F, -2.4F)); // Sakura - allow blocking with swords
public static final Item IRON_SHOVEL = registerItem("iron_shovel", properties -> new ShovelItem(ToolMaterial.IRON, 1.5F, -3.0F, properties));
public static final Item IRON_PICKAXE = registerItem("iron_pickaxe", new Item.Properties().pickaxe(ToolMaterial.IRON, 1.0F, -2.8F));
public static final Item IRON_AXE = registerItem("iron_axe", properties -> new AxeItem(ToolMaterial.IRON, 6.0F, -3.1F, properties));
public static final Item IRON_HOE = registerItem("iron_hoe", properties -> new HoeItem(ToolMaterial.IRON, -2.0F, -1.0F, properties));
- public static final Item DIAMOND_SWORD = registerItem("diamond_sword", new Item.Properties().sword(ToolMaterial.DIAMOND, 3.0F, -2.4F));
+ public static final Item DIAMOND_SWORD = registerItem("diamond_sword", properties -> new me.samsuik.sakura.player.item.BlockableSwordItem(new Item.Properties().sword(ToolMaterial.DIAMOND, 3.0F, -2.4F))); // Sakura - allow blocking with swords
+ public static final Item DIAMOND_SWORD = registerItem("diamond_sword", me.samsuik.sakura.player.item.BlockableSwordItem::new, new Item.Properties().sword(ToolMaterial.DIAMOND, 3.0F, -2.4F)); // Sakura - allow blocking with swords
public static final Item DIAMOND_SHOVEL = registerItem("diamond_shovel", properties -> new ShovelItem(ToolMaterial.DIAMOND, 1.5F, -3.0F, properties));
public static final Item DIAMOND_PICKAXE = registerItem("diamond_pickaxe", new Item.Properties().pickaxe(ToolMaterial.DIAMOND, 1.0F, -2.8F));
public static final Item DIAMOND_AXE = registerItem("diamond_axe", properties -> new AxeItem(ToolMaterial.DIAMOND, 5.0F, -3.0F, properties));
public static final Item DIAMOND_HOE = registerItem("diamond_hoe", properties -> new HoeItem(ToolMaterial.DIAMOND, -3.0F, 0.0F, properties));
- public static final Item NETHERITE_SWORD = registerItem("netherite_sword", new Item.Properties().sword(ToolMaterial.NETHERITE, 3.0F, -2.4F).fireResistant());
+ public static final Item NETHERITE_SWORD = registerItem("netherite_sword", properties -> new me.samsuik.sakura.player.item.BlockableSwordItem(new Item.Properties().sword(ToolMaterial.NETHERITE, 3.0F, -2.4F).fireResistant())); // Sakura - allow blocking with swords
+ public static final Item NETHERITE_SWORD = registerItem("netherite_sword", me.samsuik.sakura.player.item.BlockableSwordItem::new, new Item.Properties().sword(ToolMaterial.NETHERITE, 3.0F, -2.4F).fireResistant()); // Sakura - allow blocking with swords
public static final Item NETHERITE_SHOVEL = registerItem(
"netherite_shovel", properties -> new ShovelItem(ToolMaterial.NETHERITE, 1.5F, -3.0F, properties), new Item.Properties().fireResistant()
);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -108,7 +_,7 @@
@@ -109,7 +_,7 @@
public final List<TickingBlockEntity> blockEntityTickers = Lists.newArrayList();
public final NeighborUpdater neighborUpdater;
private final List<TickingBlockEntity> pendingBlockEntityTickers = Lists.newArrayList();
@@ -9,7 +9,7 @@
public final Thread thread;
private final boolean isDebug;
private int skyDarken;
@@ -158,6 +_,18 @@
@@ -159,6 +_,18 @@
return this.paperConfig;
}
// Paper end - add paper world config
@@ -28,13 +28,16 @@
public static @Nullable BlockPos lastPhysicsProblem; // Spigot
private int tileTickPosition;
@@ -203,10 +_,12 @@
@@ -827,6 +_,7 @@
org.bukkit.World.Environment env, // CraftBukkit
java.util.function.Function<org.spigotmc.SpigotWorldConfig, // Spigot - create per world config
io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, // Paper - create paper world config
+ java.util.function.Supplier<me.samsuik.sakura.configuration.WorldConfiguration> sakuraWorldConfigCreator, // Sakura - sakura configuration files
java.util.concurrent.Executor executor // Paper - Anti-Xray
) {
// Paper start - getblock optimisations - cache world height/sections
@@ -840,6 +_,7 @@
// Paper end - getblock optimisations - cache world height/sections
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName()); // Spigot
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config
+ this.sakuraConfig = sakuraWorldConfigCreator.get(); // Sakura - sakura configuration files

View File

@@ -5,10 +5,10 @@
// CraftBukkit end
public boolean excludeSourceFromDamage = true; // Paper - Allow explosions to damage source
+ private final boolean consistentRadius; // Sakura - consistent explosion radius
public ServerExplosion(
ServerLevel level,
@@ -80,6 +_,7 @@
// Paper start - collisions optimisations
private static final double[] CACHED_RAYS;
static {
@@ -323,6 +_,7 @@
this.damageSource = damageSource == null ? level.damageSources().explosion(this) : damageSource;
this.damageCalculator = damageCalculator == null ? this.makeDamageCalculator(source) : damageCalculator;
this.yield = this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F; // CraftBukkit
@@ -16,16 +16,17 @@
}
private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) {
@@ -145,7 +_,7 @@
d /= squareRoot;
d1 /= squareRoot;
d2 /= squareRoot;
- float f = this.radius * (0.7F + this.level.random.nextFloat() * 0.6F);
+ float f = this.radius * (0.7F + (this.consistentRadius ? 0.7F : this.level.random.nextFloat()) * 0.6F); // Sakura - consistent explosion radius
double d3 = this.center.x;
double d4 = this.center.y;
double d5 = this.center.z;
@@ -336,6 +_,12 @@
@@ -411,8 +_,7 @@
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);
@@ -618,6 +_,12 @@
.getBlockState(blockPos)
.onExplosionHit(this.level, blockPos, this, (itemStack, blockPos1) -> addOrAppendStack(list, itemStack, blockPos1));
}

View File

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

View File

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

View File

@@ -1,28 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
Date: Thu, 23 Sep 2021 18:50:13 +0100
Subject: [PATCH] Use maxEntityCollision limit for entity retrieval
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
index 430fefb29456dab44241d40c470ebef5fa25bb4b..647dbf5a268250c7b1c3824089dd11f6e1cec37c 100644
--- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java
@@ -3664,7 +3664,16 @@ public abstract class LivingEntity extends Entity implements Attackable {
return;
}
// Paper end - don't run getEntities if we're not going to use its result
- List<Entity> entities = this.level().getEntities(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
+ int limit = Math.max(_int, this.level().paperConfig().collisions.maxEntityCollisions);
+ int search = limit * limit;
+ List<Entity> entities = new ArrayList<>();
+ this.level().getEntities(
+ EntityTypeTest.forClass(Entity.class), this.getBoundingBox(),
+ EntitySelector.pushable(this, this.level().paperConfig().collisions.fixClimbingBypassingCrammingRule), // Paper - Climbing should not bypass cramming gamerule
+ entities, limit, search
+ );
+ // Sakura end - use maxEntityCollision limit for entity retrieval
if (!entities.isEmpty()) {
// Paper - don't run getEntities if we're not going to use its result; moved up
if (_int > 0 && entities.size() > _int - 1 && this.random.nextInt(4) == 0) {

View File

@@ -1,68 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
Date: Fri, 8 Nov 2024 19:35:49 +0000
Subject: [PATCH] Optimise check inside blocks and traverse blocks
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 2dbf517562eb2f49d426697faaf02a126d7c6b0d..f902dc11fc2797eab522edb175cc17bfa2a4cb94 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -1886,6 +1886,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
private void checkInsideBlocks(List<Entity.Movement> movements, Set<BlockState> blocksInside) {
if (this.isAffectedByBlocks()) {
LongSet set = this.visitedBlocks;
+ // Sakura start - optimise check inside blocks
+ int lastChunkX = Integer.MIN_VALUE;
+ int lastChunkZ = Integer.MIN_VALUE;
+ net.minecraft.world.level.chunk.ChunkAccess chunk = null;
+ // Sakura end - optimise check inside blocks
for (Entity.Movement movement : movements) {
Vec3 vec3 = movement.from();
@@ -1905,7 +1910,19 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return;
}
- BlockState blockState = this.level().getBlockState(blockPos);
+ // Sakura start - optimise check inside blocks
+ final int chunkX = blockPos.getX() >> 4;
+ final int chunkZ = blockPos.getZ() >> 4;
+ if (chunk == null || chunkX != lastChunkX || chunkZ != lastChunkZ) {
+ chunk = this.level.getChunkIfLoadedImmediately(chunkX, chunkZ);
+ if (chunk == null) {
+ continue;
+ }
+ lastChunkX = chunkX;
+ lastChunkZ = chunkZ;
+ }
+ final BlockState blockState = chunk.getBlockState(blockPos);
+ // Sakura end - optimise check inside blocks
if (!blockState.isAir() && set.add(blockPos.asLong())) {
try {
VoxelShape entityInsideCollisionShape = blockState.getEntityInsideCollisionShape(this.level(), blockPos);
diff --git a/net/minecraft/world/level/BlockGetter.java b/net/minecraft/world/level/BlockGetter.java
index 91865d7e78e15cc643a65de03045b90a52d6ec2a..8857887ac4fc9cb2bd08df4ccd9981d1d0e14806 100644
--- a/net/minecraft/world/level/BlockGetter.java
+++ b/net/minecraft/world/level/BlockGetter.java
@@ -214,10 +214,18 @@ public interface BlockGetter extends LevelHeightAccessor {
static Iterable<BlockPos> boxTraverseBlocks(Vec3 oldPosition, Vec3 position, AABB boundingBox) {
Vec3 vec3 = position.subtract(oldPosition);
- Iterable<BlockPos> iterable = BlockPos.betweenClosed(boundingBox);
+ // Sakura start - optimise check inside blocks
if (vec3.lengthSqr() < Mth.square(0.99999F)) {
- return iterable;
+ return me.samsuik.sakura.utils.BlockPosIterator.iterable(boundingBox);
} else {
+ final boolean xZero = vec3.x() == 0.0;
+ final boolean yZero = vec3.y() == 0.0;
+ final boolean zZero = vec3.z() == 0.0;
+ if (xZero && yZero || yZero && zZero || xZero && zZero) {
+ return me.samsuik.sakura.utils.BlockPosIterator.traverseArea(vec3, boundingBox);
+ }
+ Iterable<BlockPos> iterable = BlockPos.betweenClosed(boundingBox);
+ // Sakura end - optimise check inside blocks
Set<BlockPos> set = new ObjectLinkedOpenHashSet<>();
Vec3 minPosition = boundingBox.getMinPosition();
Vec3 vec31 = minPosition.subtract(vec3);

View File

@@ -1,4 +1,9 @@
the rejected redstone wire file patch should be a feature patch
need to look into the cactusblock changes
update the blockable sword logic
uncomment code in specialisedexplosion and tntexplosion when the moonrise patch is updated
rework & update cannon physics patch
1.21.5 block effects are no longer applied to entities while being pushed by a piston
falldistance is now a double
move classes into feature patches (so that the project can be built without moonrise)

View File

@@ -5,36 +5,33 @@ Subject: [PATCH] Client Visibility Settings
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 60861027f99a12d8364b6ebe495cc6b576cf0f48..97c36fb75d4c20946aa17295992d153abed7d28c 100644
index 13f6d27edf12628a9e3d7891ad0573aeffd1bcde..9c3d6bad289f11d7c450485557f9d9deb63887b3 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2402,6 +2402,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
handle.keepLevel = data.getBoolean("keepLevel");
}
}
+
@@ -2383,6 +2383,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
handle.expToDrop = data.getIntOr("expToDrop", 0);
handle.keepLevel = data.getBooleanOr("keepLevel", false);
});
+ // Sakura start - client visibility settings; load from nbt
+ if (nbttagcompound.contains("sakura", 10)) {
+ CompoundTag sakuraTag = nbttagcompound.getCompound("sakura");
+ CompoundTag sakuraTag = tag.getCompoundOrEmpty("sakura");
+ this.getHandle().visibilitySettings.loadData(sakuraTag);
+ }
+ // Sakura end - client visibility settings; load from nbt
}
public void setExtraData(CompoundTag nbttagcompound) {
@@ -2431,6 +2438,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void setExtraData(CompoundTag tag) {
@@ -2412,6 +2416,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
paper.putLong("LastLogin", handle.loginTime);
paper.putLong("LastSeen", System.currentTimeMillis());
// Paper end
+ // Sakura start - client visibility settings; save to nbt
+ CompoundTag sakuraTag = nbttagcompound.getCompound("sakura");
+ CompoundTag sakuraTag = tag.getCompoundOrEmpty("sakura");
+ this.getHandle().visibilitySettings.saveData(sakuraTag);
+ nbttagcompound.put("sakura", sakuraTag);
+ tag.put("sakura", sakuraTag);
+ // Sakura end - client visibility settings; save to nbt
}
@Override
@@ -3089,6 +3101,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -3072,6 +3081,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
return this.getHandle().allowsListing();
}

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Merge Cannon Entities
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java
index 22b6016a8d6828b2b10c028b24fd160b3b9f9f59..6e6c47e19610aaa4c0af9e21291800ab6400521b 100644
index 8be01a87b637a835c2c840e8281d10cd9c0566e2..100509197893cbe13745751ff1606b71cfb95115 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java
@@ -25,6 +25,27 @@ public class CraftFallingBlock extends CraftEntity implements FallingBlock {
@@ -37,7 +37,7 @@ index 22b6016a8d6828b2b10c028b24fd160b3b9f9f59..6e6c47e19610aaa4c0af9e21291800ab
@Override
public FallingBlockEntity getHandle() {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
index a61aec087fa7cec27a803668bdc1b9e6eb336755..ec29704adf8a50884bd4c38026c40158c4893a72 100644
index 465edd85d9a74f51a2bc8bddc85ddcc2aad2e39e..23fa8c8939154ebad654f3ae94aa4bdfcda033a0 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
@@ -12,6 +12,28 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Specialised Explosions
diff --git a/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java b/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java
index c21e00812f1aaa1279834a0562d360d6b89e146c..1e1329adde1457898a3002279b53b1bbb91c36d2 100644
index ece6db7b9a0dfd535141c0c756947c4898140503..b9e4971b1a0bffbe2437f940e767539fe1b3ed39 100644
--- a/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java
+++ b/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java
@@ -107,6 +107,12 @@ public final class IteratorSafeOrderedReferenceSet<E> {
@@ -127,6 +127,12 @@ public final class IteratorSafeOrderedReferenceSet<E> {
}
}

View File

@@ -1,6 +1,6 @@
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -95,6 +_,18 @@
@@ -98,6 +_,18 @@
this.entityType = CraftEntityType.minecraftToBukkit(entity.getType());
}

View File

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

View File

@@ -14,8 +14,6 @@ import net.minecraft.world.entity.item.PrimedTnt;
import net.minecraft.world.level.ExplosionDamageCalculator;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import org.bukkit.craftbukkit.util.CraftVector;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@@ -112,14 +110,13 @@ public final class TntExplosion extends SpecialisedExplosion<PrimedTnt> {
}
}
private Vector getCauseOrigin() {
Vector origin = this.cause.getOriginVector();
return origin == null ? CraftVector.toBukkit(this.center) : origin;
private Vec3 getCauseOrigin() {
return this.cause.origin == null ? this.center : this.cause.origin;
}
private EntityState nextSourceVelocity() {
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);
Vec3 origin = this.getCauseOrigin(); // valid position to use while creating a temporary entity
PrimedTnt tnt = new PrimedTnt(this.level(), origin.x(), origin.y(), origin.z(), null);
this.cause.entityState().apply(tnt);
this.impactCannonEntity(tnt, this.center, 1, this.radius() * 2.0f);
return EntityState.of(tnt);
@@ -166,7 +163,7 @@ public final class TntExplosion extends SpecialisedExplosion<PrimedTnt> {
entities.createRawIterator();
// iterate over the entityTickList to find entities that are exploding in the same position.
while ((index = entities.advanceRawIterator(index)) != -1) {
Entity foundEntity = entities.rawGet(index);
Entity foundEntity = entities.getListRaw()[index];
if (!(foundEntity instanceof MergeableEntity mergeEntity) || foundEntity.isRemoved() || !foundEntity.compareState(this.cause) || !mergeEntity.isSafeToMergeInto(this.cause, true))
break;
this.level().mergeHandler.mergeEntity(mergeEntity, this.cause);

View File

@@ -2,8 +2,13 @@ package me.samsuik.sakura.player.combat;
import it.unimi.dsi.fastutil.objects.Reference2DoubleMap;
import it.unimi.dsi.fastutil.objects.Reference2DoubleOpenHashMap;
import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap;
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
import net.minecraft.core.Holder;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.*;
import net.minecraft.world.item.component.ItemAttributeModifiers;
@@ -18,14 +23,8 @@ public final class LegacyDamageMapping {
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;
};
private interface ItemDamageRemapper {
double apply(Item item, double attackDamage);
}
static {
@@ -39,6 +38,12 @@ public final class LegacyDamageMapping {
LEGACY_ITEM_DAMAGE_MAP.put(Items.DIAMOND_AXE, 6.0);
LEGACY_ITEM_DAMAGE_MAP.put(Items.NETHERITE_AXE, 7.0);
Reference2ObjectMap<TagKey<Item>, ItemDamageRemapper> remapUsingItemTags = new Reference2ObjectArrayMap<>();
remapUsingItemTags.put(ItemTags.SWORDS, (item, attack) -> 1.0);
remapUsingItemTags.put(ItemTags.PICKAXES, (item, attack) -> 1.0);
remapUsingItemTags.put(ItemTags.SHOVELS, (item, attack) -> -0.5);
remapUsingItemTags.put(ItemTags.HOES, (item, attack) -> -attack);
for (Item item : BuiltInRegistries.ITEM) {
ItemAttributeModifiers modifiers = item.components().get(DataComponents.ATTRIBUTE_MODIFIERS);
@@ -46,7 +51,8 @@ public final class LegacyDamageMapping {
continue;
}
assert item instanceof AxeItem : "missing axe mapping";
Holder.Reference<Item> itemHolder = item.builtInRegistryHolder();
assert itemHolder.is(ItemTags.AXES) : "missing axe mapping";
double attackDamage = modifiers.modifiers().stream()
.filter(e -> e.attribute().is(Attributes.ATTACK_DAMAGE))
@@ -54,7 +60,14 @@ public final class LegacyDamageMapping {
.sum();
if (attackDamage > 0.0) {
double adjustment = adjustDamageForItem(item, attackDamage);
double adjustment = 0.0;
for (TagKey<Item> key : remapUsingItemTags.keySet()) {
if (itemHolder.is(key)) {
ItemDamageRemapper remapper = remapUsingItemTags.get(key);
adjustment = remapper.apply(item, attackDamage);
}
}
LEGACY_ITEM_DAMAGE_MAP.put(item, attackDamage + adjustment);
}
}

View File

@@ -26,7 +26,7 @@ public final class LegacyGoldenAppleItem extends Item {
new ApplyStatusEffectsConsumeEffect(
List.of(
new MobEffectInstance(MobEffects.REGENERATION, 600, 4),
new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 6000, 0),
new MobEffectInstance(MobEffects.RESISTANCE, 6000, 0),
new MobEffectInstance(MobEffects.FIRE_RESISTANCE, 6000, 0),
new MobEffectInstance(MobEffects.ABSORPTION, 2400, 0)
)