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

Add local storage and config api

This commit is contained in:
Samsuik
2023-11-22 14:58:36 +00:00
parent 3df4f2a0ce
commit 2d993ce6e1
37 changed files with 527 additions and 94 deletions

View File

@@ -0,0 +1,180 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
Date: Tue, 21 Nov 2023 23:22:35 +0000
Subject: [PATCH] Local Value Storage API
diff --git a/src/main/java/me/samsuik/sakura/local/LocalRegion.java b/src/main/java/me/samsuik/sakura/local/LocalRegion.java
new file mode 100644
index 0000000000000000000000000000000000000000..34a0755da6c471a51fb18a5e139af42df1362a93
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/local/LocalRegion.java
@@ -0,0 +1,36 @@
+package me.samsuik.sakura.local;
+
+import org.bukkit.Location;
+
+public record LocalRegion(int minX, int minZ, int maxX, int maxZ) {
+
+ public static LocalRegion of(Location min, Location max) {
+ return of(min.getBlockX(), min.getBlockZ(), max.getBlockX(), max.getBlockZ());
+ }
+
+ public static LocalRegion of(int minX, int minZ, int maxX, int maxZ) {
+ return new LocalRegion(
+ Math.min(minX, maxX), Math.min(minZ, maxZ),
+ Math.max(minX, maxX), Math.max(minZ, maxZ)
+ );
+ }
+
+ public static LocalRegion at(int x, int z, int radius) {
+ return new LocalRegion(x-radius, z-radius, x+radius, z+radius);
+ }
+
+ public boolean intersects(LocalRegion region) {
+ return (minX < region.minX() && maxX > region.minX() || maxX > region.maxX() && minX < region.maxX())
+ && (minZ < region.minZ() && maxZ > region.minZ() || maxZ > region.maxZ() && minZ < region.maxZ());
+ }
+
+ public boolean contains(LocalRegion region) {
+ return minX < region.minX() && maxX > region.maxX()
+ && maxZ < region.minZ() && maxZ > region.maxZ();
+ }
+
+ public boolean contains(int x, int z) {
+ return minX <= x && maxX >= x && minZ <= z && maxZ >= z;
+ }
+
+}
diff --git a/src/main/java/me/samsuik/sakura/local/LocalValueKey.java b/src/main/java/me/samsuik/sakura/local/LocalValueKey.java
new file mode 100644
index 0000000000000000000000000000000000000000..4735e5d8dcea4835061b5cada9d601794efdf390
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/local/LocalValueKey.java
@@ -0,0 +1,38 @@
+package me.samsuik.sakura.local;
+
+import me.samsuik.sakura.physics.PhysicsVersion;
+import org.bukkit.Material;
+import org.bukkit.NamespacedKey;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.function.Supplier;
+
+public record LocalValueKey<T>(NamespacedKey key, Supplier<T> defaultSupplier) {
+
+ // ...
+ public static final LocalValueKey<PhysicsVersion> PHYSICS_VERSION = new LocalValueKey<>(
+ new NamespacedKey("sakura", "physics-version"), () -> PhysicsVersion.LATEST
+ );
+
+ public static final LocalValueKey<Map<Material, Map.Entry<Integer, Float>>> DURABLE_MATERIALS = new LocalValueKey<>(
+ new NamespacedKey("sakura", "durable-materials"), HashMap::new
+ );
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ LocalValueKey<?> that = (LocalValueKey<?>) o;
+
+ return Objects.equals(key, that.key);
+ }
+
+ @Override
+ public int hashCode() {
+ return key != null ? key.hashCode() : 0;
+ }
+
+}
diff --git a/src/main/java/me/samsuik/sakura/local/storage/LocalStorageHandler.java b/src/main/java/me/samsuik/sakura/local/storage/LocalStorageHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..5c971fb4266f46de258767fccaf7fe55be467886
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/local/storage/LocalStorageHandler.java
@@ -0,0 +1,24 @@
+package me.samsuik.sakura.local.storage;
+
+import me.samsuik.sakura.local.LocalRegion;
+import org.bukkit.Location;
+
+import java.util.List;
+
+public interface LocalStorageHandler {
+
+ LocalRegion locate(Location location, int searchDistance);
+
+ LocalRegion locate(int x, int z, int searchDistance);
+
+ LocalValueStorage get(LocalRegion region);
+
+ boolean has(LocalRegion region);
+
+ void put(LocalRegion region, LocalValueStorage storage);
+
+ void remove(LocalRegion region);
+
+ List<LocalRegion> regions();
+
+}
diff --git a/src/main/java/me/samsuik/sakura/local/storage/LocalValueStorage.java b/src/main/java/me/samsuik/sakura/local/storage/LocalValueStorage.java
new file mode 100644
index 0000000000000000000000000000000000000000..0f7da96d434cd699470e050898712898b54fa356
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/local/storage/LocalValueStorage.java
@@ -0,0 +1,37 @@
+package me.samsuik.sakura.local.storage;
+
+import me.samsuik.sakura.local.LocalValueKey;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public final class LocalValueStorage {
+
+ private final Map<LocalValueKey<?>, Object> map = new HashMap<>();
+
+ public boolean exists(LocalValueKey<?> key) {
+ return this.map.containsKey(key);
+ }
+
+ public <T> T value(LocalValueKey<T> key) {
+ return (T) this.map.get(key);
+ }
+
+ public <T> T value(LocalValueKey<T> key, boolean def) {
+ T val = (T) this.map.get(key);
+ if (!def || val != null)
+ return val;
+ // update value
+ this.set(key, val = key.defaultSupplier().get());
+ return val;
+ }
+
+ public <T> void set(LocalValueKey<T> key, T insert) {
+ this.map.put(key, insert);
+ }
+
+ public void remove(LocalValueKey<?> key) {
+ this.map.remove(key);
+ }
+
+}
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 5eb3521f5f91b0684b4beebf4f7ba2c795b41c42..5f0cb37bd3384922c4ae2a238d5549db48f16c16 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -131,6 +131,10 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
return new Location(this, x, y, z);
}
// Paper end
+ // Sakura start
+ @NotNull
+ me.samsuik.sakura.local.storage.LocalStorageHandler getStorageHandler();
+ // Sakura end
/**
* Gets the highest non-empty (impassable) block at the given coordinates.

View File

@@ -0,0 +1,258 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
Date: Tue, 21 Nov 2023 23:24:24 +0000
Subject: [PATCH] Local Config and Value Storage API
diff --git a/src/main/java/me/samsuik/sakura/local/config/LocalConfigManager.java b/src/main/java/me/samsuik/sakura/local/config/LocalConfigManager.java
new file mode 100644
index 0000000000000000000000000000000000000000..3508755c11cc8f577d27a440f2f4a08d9856f5ae
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/local/config/LocalConfigManager.java
@@ -0,0 +1,143 @@
+package me.samsuik.sakura.local.config;
+
+import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
+import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
+import it.unimi.dsi.fastutil.longs.Long2ObjectRBTreeMap;
+import it.unimi.dsi.fastutil.longs.Long2ObjectSortedMap;
+import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
+import me.samsuik.sakura.local.LocalRegion;
+import me.samsuik.sakura.local.storage.LocalStorageHandler;
+import me.samsuik.sakura.local.storage.LocalValueStorage;
+import me.samsuik.sakura.utils.objects.Expiry;
+import net.minecraft.core.BlockPos;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.world.level.ChunkPos;
+import net.minecraft.world.level.Level;
+import org.bukkit.Location;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class LocalConfigManager implements LocalStorageHandler {
+
+ private final Map<LocalRegion, LocalValueStorage> storageMap = new Object2ObjectOpenHashMap<>();
+ // tree is a tree. it may not be correct but it works.
+ private final Long2ObjectRBTreeMap<LocalRegion> regionTree = new Long2ObjectRBTreeMap<>();
+ private final Long2ObjectMap<LocalValueConfig> configMap = new Long2ObjectOpenHashMap<>();
+ private final Level level;
+
+ public LocalConfigManager(Level level) {
+ this.level = level;
+ }
+
+ @Override
+ public LocalRegion locate(Location location, int searchDistance) {
+ return this.locate(location.getBlockX(), location.getBlockZ(), searchDistance);
+ }
+
+ @Override
+ public LocalRegion locate(int x, int z, int searchDistance) {
+ long search = (long) searchDistance << 32;
+ long coordinate = ChunkPos.asLong(x, z);
+
+ // all regions below the coordinate (they're stored with the minX, minZ)
+ Long2ObjectSortedMap<LocalRegion> head = this.regionTree.headMap(coordinate);
+
+ if (head.isEmpty()) return null;
+
+ for (Long2ObjectMap.Entry<LocalRegion> entry : head.long2ObjectEntrySet()) {
+ // this has no respect for the x coordinate, but it works
+ if (coordinate - entry.getLongKey() > search) {
+ break;
+ }
+
+ // check if the region we found contains the position
+ if (entry.getValue().contains(x, z)) {
+ return entry.getValue();
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public LocalValueStorage get(LocalRegion region) {
+ return this.storageMap.get(region);
+ }
+
+ @Override
+ public boolean has(LocalRegion region) {
+ return this.storageMap.containsKey(region);
+ }
+
+ @Override
+ public void put(LocalRegion region, LocalValueStorage storage) {
+ assert region != null : "region cannot be null";
+ assert storage != null : "storage cannot be null";
+
+ long base = ChunkPos.asLong(region.minX(), region.minZ());
+ this.ensureNotOverlapping(region);
+
+ this.storageMap.put(region, storage);
+ this.regionTree.put(base, region);
+ }
+
+ @Override
+ public void remove(LocalRegion region) {
+ assert region != null : "region cannot be null";
+
+ long base = ChunkPos.asLong(region.minX(), region.minZ());
+
+ this.storageMap.remove(region);
+ this.regionTree.remove(base);
+ }
+
+ @Override
+ public List<LocalRegion> regions() {
+ return new ArrayList<>(this.storageMap.keySet());
+ }
+
+ public LocalValueConfig config(BlockPos position) {
+ long chunkKey = ChunkPos.asLong(position.getX() >> 4, position.getZ() >> 4);
+
+ LocalValueConfig local = this.configMap.computeIfAbsent(chunkKey, (key) -> {
+ LocalValueConfig config = new LocalValueConfig(new Expiry(MinecraftServer.currentTickLong, 600));
+
+ // defaults from sakura config
+ config.init(level);
+
+ // search the entire map if we have to for a region
+ LocalRegion region = this.locate(position.getX(), position.getZ(), Integer.MAX_VALUE);
+
+ if (region != null) {
+ // load local values
+ config.load(this.storageMap.get(region));
+ }
+
+ return config;
+ });
+
+ local.expiry().refresh(MinecraftServer.currentTickLong);
+ return local;
+ }
+
+ public void expire(long tick) {
+ if (tick % 200 != 0) return;
+
+ // remove expired
+ this.configMap.values().removeIf(obj -> obj.expiry().isExpired(tick));
+ }
+
+ private void ensureNotOverlapping(LocalRegion region) {
+ long top = ChunkPos.asLong(region.maxX(), region.maxZ());
+ Long2ObjectSortedMap<LocalRegion> head = this.regionTree.headMap(top);
+
+ for (LocalRegion present : head.values()) {
+ if (present != region && present.intersects(region)) {
+ throw new UnsupportedOperationException("overlapping regions");
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/me/samsuik/sakura/local/config/LocalValueConfig.java b/src/main/java/me/samsuik/sakura/local/config/LocalValueConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..90f0d417bdc9d27c16cf8500aae9152f7d0406c5
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/local/config/LocalValueConfig.java
@@ -0,0 +1,49 @@
+package me.samsuik.sakura.local.config;
+
+import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
+import me.samsuik.sakura.explosion.durable.DurableMaterial;
+import me.samsuik.sakura.local.LocalValueKey;
+import me.samsuik.sakura.local.storage.LocalValueStorage;
+import me.samsuik.sakura.utils.objects.Expiry;
+import net.minecraft.world.level.Level;
+import me.samsuik.sakura.physics.PhysicsVersion;
+import net.minecraft.world.level.block.Block;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+
+import java.util.Map;
+
+public class LocalValueConfig {
+
+ private final Expiry expiry;
+ public Map<Block, DurableMaterial> durableMaterials;
+ public PhysicsVersion physicsVersion;
+
+ LocalValueConfig(Expiry expiry) {
+ this.expiry = expiry;
+ }
+
+ void init(Level level) {
+ // default materials
+ this.durableMaterials = new Reference2ObjectOpenHashMap<>(level.sakuraConfig().cannons.explosion.durableMaterials);
+
+ // physics version
+ this.physicsVersion = level.sakuraConfig().cannons.mechanics.physicsVersion;
+ }
+
+ void load(LocalValueStorage storage) {
+ // local materials
+ storage.value(LocalValueKey.DURABLE_MATERIALS, true).forEach(((material, entry) -> {
+ this.durableMaterials.put(CraftMagicNumbers.getBlock(material), new DurableMaterial(entry.getKey(), entry.getValue()));
+ }));
+
+ // physics version
+ if (storage.exists(LocalValueKey.PHYSICS_VERSION)) {
+ this.physicsVersion = storage.value(LocalValueKey.PHYSICS_VERSION);
+ }
+ }
+
+ Expiry expiry() {
+ return expiry;
+ }
+
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 9c5c633587d6781a72d9eb258ba5a4a35e954144..63d11c4db7152a7bb5aaf5fc625d8f8e585cafa0 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1575,6 +1575,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.profiler.pop();
this.profiler.pop();
worldserver.explosionDensityCache.clear(); // Paper - Optimize explosions
+ worldserver.localConfig().expire(currentTickLong); // Sakura
}
this.isIteratingOverLevels = false; // Paper
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 11ab3a3b8624c36dfde3d42091af67c51340e8f2..cd2d2db3b3024ed40aaeb478d6e52e9c7c168107 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -180,6 +180,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return this.sakuraConfig;
}
// Sakura end
+ // Sakura start
+ private final me.samsuik.sakura.local.config.LocalConfigManager localConfig = new me.samsuik.sakura.local.config.LocalConfigManager(this);
+
+ public me.samsuik.sakura.local.config.LocalConfigManager localConfig() {
+ return this.localConfig;
+ }
+ // Sakura end
public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray
public final co.aikar.timings.WorldTimingsHandler timings; // Paper
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index c3060d1d4d0caf369c6ab516cb424f45eb851019..871ad0128856ad672dda645769efc90ec437ebd7 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -229,6 +229,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
}
// Paper end
+ // Sakura start
+ @Override
+ public me.samsuik.sakura.local.storage.LocalStorageHandler getStorageHandler() {
+ return this.getHandle().localConfig();
+ }
+ // Sakura end
+
private static final Random rand = new Random();
public CraftWorld(ServerLevel world, ChunkGenerator gen, BiomeProvider biomeProvider, Environment env) {

View File

@@ -240,13 +240,13 @@ index e3f355c85eb7cc8c1683e3009502c10a5ed32daa..349e56d5caad3fc38e83eac6ffff83e2
public ClientboundSectionBlocksUpdatePacket(SectionPos sectionPos, ShortSet positions, LevelChunkSection section) {
this.sectionPos = sectionPos;
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 9c5c633587d6781a72d9eb258ba5a4a35e954144..ed5c391750f2f895be40713eb2e8bfed7cb9448b 100644
index 63d11c4db7152a7bb5aaf5fc625d8f8e585cafa0..681091462217b1c4176f8892563a681a3c8a9c06 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1575,6 +1575,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.profiler.pop();
@@ -1576,6 +1576,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.profiler.pop();
worldserver.explosionDensityCache.clear(); // Paper - Optimize explosions
worldserver.localConfig().expire(currentTickLong); // Sakura
+ worldserver.minimalTNT.clear(); // Sakura - visibility api
}
this.isIteratingOverLevels = false; // Paper
@@ -380,7 +380,7 @@ index 35674f92a67f93382103c2766df4b678ba5c862f..83c4639c2bdca4dc4281d9f5eca104af
if (this.entity instanceof LivingEntity) {
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index c661de08862b4619f7d75606cac9a913fe154386..93cca48032e5d95d9d07eae3393a2babdf9a3aa5 100644
index 9d860f15b13a3daa2f3b44c96f9b18e33828dd15..b48186e142c803d1371cf441542119962862ed07 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1932,7 +1932,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -587,10 +587,10 @@ index 4ce3e69970dd9eb251d0538a2d233ca30e9e5e47..d14a8e2cf748cb3784253d99d1bf3c8f
public PrimedTnt(Level world, double x, double y, double z, @Nullable LivingEntity igniter) {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 11ab3a3b8624c36dfde3d42091af67c51340e8f2..23945f078070c94785ea00320113c0849a79981f 100644
index cd2d2db3b3024ed40aaeb478d6e52e9c7c168107..b5b19105f33b27a6ade70e914a2e19c024325b86 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -216,6 +216,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -223,6 +223,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public abstract ResourceKey<LevelStem> getTypeKey();

View File

@@ -420,7 +420,7 @@ index 0000000000000000000000000000000000000000..8a94b1a2cb1ff57664c97a7b471c99ec
+
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 4535beab09310915b0239b01c1b807f1ca25d959..eef411f838ecdeff0d4052fac22900e4ad87ceb5 100644
index 681091462217b1c4176f8892563a681a3c8a9c06..e1da429e78ee7445d2243661efbf08e152c8c732 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1080,6 +1080,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -448,7 +448,7 @@ index 4535beab09310915b0239b01c1b807f1ca25d959..eef411f838ecdeff0d4052fac22900e4
this.mayHaveDelayedTasks = true;
this.delayedTasksMaxNextTickTime = Math.max(Util.getMillis() + 50L, this.nextTickTime);
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 17b6925b46f8386dcfc561483693de516465ec12..3a925f6bd215f14878bd397aa3f0d7b6eda92ce1 100644
index 8c33a12ca879c46893150d6adfb8aa4d397c6b4c..fe8da490f50a74bf6a0327b9c31a258c3d79d8e6 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -76,6 +76,12 @@ public class ServerChunkCache extends ChunkSource {
@@ -465,7 +465,7 @@ index 17b6925b46f8386dcfc561483693de516465ec12..3a925f6bd215f14878bd397aa3f0d7b6
return x & 3 | ((z & 3) << 2);
}
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index a9cd388c7ebb377511f59398b8f31a04d7abe493..bc73d8625ac296372640f540ade170aed8ae5353 100644
index b48186e142c803d1371cf441542119962862ed07..efba8d153b5838ff1dbc68d389b4d1529c951008 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -192,7 +192,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -495,7 +495,7 @@ index 4cdfc433df67afcd455422e9baf56f167dd712ae..1fcce60790cab6e7b137464ccd87e678
// Paper - replace with better logic, do not delay removals
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 612c3169c3463d702b85975e1db79ae6e47d60d0..2063a6c6ab0786aee51be027950c2a936f593b55 100644
index 68602dfb171d47e47fd0710b4324013ef05214d0..6f21afd958fbb7037611ca01458b6848b93cc208 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -283,7 +283,7 @@ public class SpigotConfig

View File

@@ -41,10 +41,10 @@ index 2d79633d86007c7d40eecf5f9271fa3f351b72b5..d917a19c838ed3d74322abd85e1f737e
public void getEntities(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate) {
if (this.count == 0) {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 9e49196f7038c710e850005b6ad96c4eafca0f2e..a29d41bf162c923e3b3b15e7500e0c8693908866 100644
index b5b19105f33b27a6ade70e914a2e19c024325b86..7354a93826cbb977829fae1b2d91de24fcd867c1 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -218,6 +218,16 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -225,6 +225,16 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public final it.unimi.dsi.fastutil.longs.Long2IntMap minimalTNT = new it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap(); // Sakura - visibility api

View File

@@ -52,7 +52,7 @@ index 0000000000000000000000000000000000000000..c9f2c5ae57878283e8c8bc3847fe63b9
+
+}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index f9df441564c7021677f270b481976ba04357af10..b1e8cc0da8d6754946ca05745256ea0b144757cb 100644
index a6c42038cba6b272a472a2b6c78cf741ff8228fd..9118ebf8c0f2fc4cb8fb438426ef49cbdf9acc52 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -534,6 +534,34 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -91,10 +91,10 @@ index f9df441564c7021677f270b481976ba04357af10..b1e8cc0da8d6754946ca05745256ea0b
public boolean isLegacyTrackingEntity = false;
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 82fbf025e70d48d535360508ea96c9e8007978c7..7a21fe6e7109eaa1eca38c7503cc4d331e9c66c5 100644
index 7354a93826cbb977829fae1b2d91de24fcd867c1..12c6705d652cf873134aca556e205aa5ec0248fb 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -1325,6 +1325,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -1332,6 +1332,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public <T extends Entity> void guardEntityTick(Consumer<T> tickConsumer, T entity) {
try {

View File

@@ -149,19 +149,19 @@ index 0000000000000000000000000000000000000000..7cb3b0d5a284199cdc117038227d3368
+
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index d559fb2adbebd47d8be75c9dd3477edfca142790..a520e0dbbe2b5baaeba32020d217b5f08870044b 100644
index e1da429e78ee7445d2243661efbf08e152c8c732..457ccc9934fc6563a1b260ec9d12f0c875a4bd37 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1579,6 +1579,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.profiler.pop();
@@ -1580,6 +1580,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
worldserver.explosionDensityCache.clear(); // Paper - Optimize explosions
worldserver.localConfig().expire(currentTickLong); // Sakura
worldserver.minimalTNT.clear(); // Sakura - visibility api
+ worldserver.mergeHistory.expire(currentTickLong); // Sakura - merge cannoning entities
}
this.isIteratingOverLevels = false; // Paper
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index f3da674ae3a38a6c7af488580a685eb4c1523e0c..6beee8db675d737dc492065f0f12b617c5426694 100644
index efba8d153b5838ff1dbc68d389b4d1529c951008..fd25999781d99526b1bc1677aaa3ff742b216ac5 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -877,6 +877,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -487,10 +487,10 @@ index fbeb52a49b791f992af19c7d69ba44b820541b09..02ef6ca32f3de52e921fdcf3f0f572ce
this.explode();
}
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 7a21fe6e7109eaa1eca38c7503cc4d331e9c66c5..e84b1167c2606bcc1b5ce1e284a6208e3e0b0860 100644
index 12c6705d652cf873134aca556e205aa5ec0248fb..c7defb4555edd792c83ec001c8dfbf604376b190 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -227,6 +227,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -234,6 +234,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return slices.getSectionEntities(chunkY);
}
// Sakura end

View File

@@ -600,11 +600,11 @@ index 0000000000000000000000000000000000000000..e0387f16ff49031fdcbc8990613417da
+
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index a520e0dbbe2b5baaeba32020d217b5f08870044b..805396ad55b551080e5796cbbc493fe10d2997b6 100644
index 457ccc9934fc6563a1b260ec9d12f0c875a4bd37..d2b12606c4bd7edec4061f67e79bdedcee147fca 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1580,6 +1580,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
worldserver.explosionDensityCache.clear(); // Paper - Optimize explosions
@@ -1581,6 +1581,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
worldserver.localConfig().expire(currentTickLong); // Sakura
worldserver.minimalTNT.clear(); // Sakura - visibility api
worldserver.mergeHistory.expire(currentTickLong); // Sakura - merge cannoning entities
+ worldserver.densityCache.clear(); // Sakura
@@ -959,10 +959,10 @@ index 1b335111bd9eb90bbda87225b740768705f26193..11ce5591f5f7eb487323e2c828218af2
return blockDensity;
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index e84b1167c2606bcc1b5ce1e284a6208e3e0b0860..907babe5d01262d0c2d7d1edb7e4882a5503c5f6 100644
index c7defb4555edd792c83ec001c8dfbf604376b190..3e1271d07883f05fff21d0ec6088fe42a579a706 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -228,6 +228,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -235,6 +235,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
}
// Sakura end
public final me.samsuik.sakura.entity.merge.MergeHistory mergeHistory = new me.samsuik.sakura.entity.merge.MergeHistory(); // Sakura
@@ -970,7 +970,7 @@ index e84b1167c2606bcc1b5ce1e284a6208e3e0b0860..907babe5d01262d0c2d7d1edb7e4882a
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, Supplier<me.samsuik.sakura.configuration.WorldConfiguration> sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - Async-Anti-Xray - Pass executor
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
@@ -1406,7 +1407,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -1413,7 +1414,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
}
Explosion.BlockInteraction explosion_effect1 = explosion_effect;

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Optimise Fast Movement
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 22c43e5a12c254da2d427af28012adfb39f0ce7f..d5b1e5bef63e148aeff1c0296e909b35167e753c 100644
index 639712fe3e81703791b87622ae598c11b274802f..97b11192592f67c976dc5567cfeaad55e7780c18 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1198,6 +1198,95 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -205,7 +205,7 @@ index 22c43e5a12c254da2d427af28012adfb39f0ce7f..d5b1e5bef63e148aeff1c0296e909b35
// Paper start - optimise collisions
final boolean xZero = movement.x == 0.0;
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index f9d2ec92e46f7f0ca2a6c93b90d9a5afa2047658..bf28a02842cc5c8af23c3be2bc1e317c24074781 100644
index 45e042dc8b875b08f5f09955258913a256371b54..2c1d29c560d1f68456283144ee7342f331705225 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -201,7 +201,7 @@ public class FallingBlockEntity extends Entity {

View File

@@ -329,10 +329,10 @@ index d917a19c838ed3d74322abd85e1f737e852b5d7b..1ba10713c85d6f19f075cc267602a04c
if (this.count == 0) {
return;
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 907babe5d01262d0c2d7d1edb7e4882a5503c5f6..a17ea99a4de4f69ca95a67f9a9b977b49148a261 100644
index 3e1271d07883f05fff21d0ec6088fe42a579a706..6fca6c3d8200251e24f3df886f17f35179b1f760 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -230,6 +230,39 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -237,6 +237,39 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public final me.samsuik.sakura.entity.merge.MergeHistory mergeHistory = new me.samsuik.sakura.entity.merge.MergeHistory(); // Sakura
public final me.samsuik.sakura.explosion.DensityCache densityCache = new me.samsuik.sakura.explosion.DensityCache();

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] isPushedByFluid API
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index d5b1e5bef63e148aeff1c0296e909b35167e753c..12b830a03db2752fce26085daaa6e41c14858a48 100644
index 97b11192592f67c976dc5567cfeaad55e7780c18..02d4d2599340d22d8d501b2466b12f0f3216451b 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -661,6 +661,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -26,7 +26,7 @@ index d5b1e5bef63e148aeff1c0296e909b35167e753c..12b830a03db2752fce26085daaa6e41c
public static double getViewScale() {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 0e6c7284b9aee6c5f2454a3a095ebf349f887740..9ab085add965825ce59fc38eb390d6b6ae9cbf84 100644
index 9f843b89dc20b91bf7243facee8486d525e4a1b3..0ca488d26b137d553a0b8c96629c1080a1303ca5 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -548,6 +548,18 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Cannon Mechanics
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index b592416daef8233a08537267c79290c6758250b4..0ebb06d3f8350dc4d4a931f339c872f9943b7631 100644
index 2c1d29c560d1f68456283144ee7342f331705225..69f5f03a8e43f1e7370981009fe2376294b7253a 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -67,6 +67,7 @@ public class FallingBlockEntity extends Entity {
@@ -64,7 +64,7 @@ index f661c6225401dba8bb13edcc72fb919a2c76d675..3818d07261ce4f276968691ad32a22b8
// Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java
index 55bfb0afc0e4e9f1ce2dd15f729bee61822c5afc..69b3682783308d188929742f738ec71df973eb03 100644
index c64ab06b62334e5ab1ab5ad78fa400de45c15723..94667eab6d756ee170eb49e2e434c7a3b0df2d67 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java
@@ -34,6 +34,16 @@ public class CraftFallingBlock extends CraftEntity implements FallingBlock {

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Optimise TNT fluid state and pushing
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 12b830a03db2752fce26085daaa6e41c14858a48..ffa7c83519bbd2aea4485c97ac29961f91e267c2 100644
index 02d4d2599340d22d8d501b2466b12f0f3216451b..50259042ebafe520342bdb1a4b7e6b9138b8acbd 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2168,7 +2168,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {

View File

@@ -74,10 +74,10 @@ index 0000000000000000000000000000000000000000..2e11ba36e9e820f17839d696e5d7d876
+
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 805396ad55b551080e5796cbbc493fe10d2997b6..c061991f23748395fe07205e80b288b166c07c49 100644
index d2b12606c4bd7edec4061f67e79bdedcee147fca..4c2dc25419662c491097a53f2a730b805269da05 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1581,6 +1581,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1582,6 +1582,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
worldserver.minimalTNT.clear(); // Sakura - visibility api
worldserver.mergeHistory.expire(currentTickLong); // Sakura - merge cannoning entities
worldserver.densityCache.clear(); // Sakura
@@ -86,7 +86,7 @@ index 805396ad55b551080e5796cbbc493fe10d2997b6..c061991f23748395fe07205e80b288b1
this.isIteratingOverLevels = false; // Paper
diff --git a/src/main/java/net/minecraft/world/item/ItemNameBlockItem.java b/src/main/java/net/minecraft/world/item/ItemNameBlockItem.java
index a8008c7550488be34b51f4280f5569170b1ebd1d..82a68c0039feea8519477d6542a6e339a7f028f2 100644
index a8008c7550488be34b51f4280f5569170b1ebd1d..b10cfec6da6dfab89e585c5d4d39ae04f7d2e43d 100644
--- a/src/main/java/net/minecraft/world/item/ItemNameBlockItem.java
+++ b/src/main/java/net/minecraft/world/item/ItemNameBlockItem.java
@@ -7,6 +7,33 @@ public class ItemNameBlockItem extends BlockItem {
@@ -99,12 +99,12 @@ index a8008c7550488be34b51f4280f5569170b1ebd1d..82a68c0039feea8519477d6542a6e339
+ Block itemBlock = this.getBlock();
+ if (context.getPlayer() != null && itemBlock.equals(net.minecraft.world.level.block.Blocks.POTATOES)) {
+ net.minecraft.world.entity.player.Player player = context.getPlayer();
+ net.minecraft.world.level.block.state.BlockState state = player.level().getBlockState(context.getClickedPos());
+ net.minecraft.world.level.block.state.BlockState state = context.getLevel().getBlockState(context.getClickedPos());
+ Block block = state.getBlock();
+ me.samsuik.sakura.explosion.durable.DurableMaterial material = player.level().sakuraConfig().cannons.explosion.durableMaterials.get(block);
+ me.samsuik.sakura.explosion.durable.DurableMaterial material = context.getLevel().localConfig().config(context.getClickedPos()).durableMaterials.get(block);
+
+ if (material != null) {
+ int durability = player.level().durabilityManager.durability(context.getClickedPos(), material);
+ int durability = context.getLevel().durabilityManager.durability(context.getClickedPos(), material);
+ this.sendPotatoMessage(player, durability, material.durability());
+ }
+ }
@@ -124,7 +124,7 @@ index a8008c7550488be34b51f4280f5569170b1ebd1d..82a68c0039feea8519477d6542a6e339
public String getDescriptionId() {
return this.getOrCreateDescriptionId();
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index 11ce5591f5f7eb487323e2c828218af2461fca09..eb609c7b7e8de093ba1934d35e4085cbb4648a05 100644
index 11ce5591f5f7eb487323e2c828218af2461fca09..184da2f99fdcf0c3750457f38e754918efc6d0bb 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -198,6 +198,17 @@ public class Explosion {
@@ -134,7 +134,7 @@ index 11ce5591f5f7eb487323e2c828218af2461fca09..eb609c7b7e8de093ba1934d35e4085cb
+ // Sakura start - durable materials
+ if (calculateResistance) {
+ Block block = blockState.getBlock();
+ me.samsuik.sakura.explosion.durable.DurableMaterial material = this.level.sakuraConfig().cannons.explosion.durableMaterials.get(block);
+ me.samsuik.sakura.explosion.durable.DurableMaterial material = this.level.localConfig().config(pos).durableMaterials.get(block);
+
+ if (material != null && material.resistance() >= 0.0f) {
+ resistance = Optional.of(material.resistance());
@@ -150,7 +150,7 @@ index 11ce5591f5f7eb487323e2c828218af2461fca09..eb609c7b7e8de093ba1934d35e4085cb
BlockState iblockdata = this.level.getBlockState(blockposition);
Block block = iblockdata.getBlock();
+ // Sakura start - durable materials
+ me.samsuik.sakura.explosion.durable.DurableMaterial material = level.sakuraConfig().cannons.explosion.durableMaterials.get(block);
+ me.samsuik.sakura.explosion.durable.DurableMaterial material = level.localConfig().config(blockposition).durableMaterials.get(block);
+
+ if (material != null && material.durability() >= 0 && !level.durabilityManager.damage(blockposition, material)) {
+ objectlistiterator.remove();
@@ -161,10 +161,10 @@ index 11ce5591f5f7eb487323e2c828218af2461fca09..eb609c7b7e8de093ba1934d35e4085cb
if (block instanceof net.minecraft.world.level.block.TntBlock) {
Entity sourceEntity = this.source == null ? null : this.source;
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index a17ea99a4de4f69ca95a67f9a9b977b49148a261..1de55269a2abcdacb4c47afdfba72d6a26c22a01 100644
index 6fca6c3d8200251e24f3df886f17f35179b1f760..3d133380c70c6ef471dd42280bbd269ef72d2e6d 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -229,6 +229,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -236,6 +236,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// Sakura end
public final me.samsuik.sakura.entity.merge.MergeHistory mergeHistory = new me.samsuik.sakura.entity.merge.MergeHistory(); // Sakura
public final me.samsuik.sakura.explosion.DensityCache densityCache = new me.samsuik.sakura.explosion.DensityCache();

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Destroy Waterlogged Blocks
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index b2f42287db6d107c7e8adabd98f007e6b9c7d42b..793b41e52ff024f2bd1085876f275ffb36ec94c1 100644
index 20d1d4ef3f205b278b1c881035e9dce5b1474bb5..2e787079956c863ffd626acc77323a955e7d9871 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -196,6 +196,12 @@ public class Explosion {

View File

@@ -341,10 +341,10 @@ index 0000000000000000000000000000000000000000..f9ffc75f3c349c6a1cb614ed925b2e90
+
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index c061991f23748395fe07205e80b288b166c07c49..d4a0594a8ada4cfbd1f46a9dc0604c79e6ae0cd6 100644
index 4c2dc25419662c491097a53f2a730b805269da05..de4a9d68585c767b38f662cf3c06f89e5705d8ec 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1582,6 +1582,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1583,6 +1583,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
worldserver.mergeHistory.expire(currentTickLong); // Sakura - merge cannoning entities
worldserver.densityCache.clear(); // Sakura
worldserver.durabilityManager.expire(currentTickLong); // Sakura
@@ -353,10 +353,10 @@ index c061991f23748395fe07205e80b288b166c07c49..d4a0594a8ada4cfbd1f46a9dc0604c79
this.isIteratingOverLevels = false; // Paper
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 1de55269a2abcdacb4c47afdfba72d6a26c22a01..9f103669880e1c40b8e12b65d5ffb30d0ca120fe 100644
index 3d133380c70c6ef471dd42280bbd269ef72d2e6d..cac37ebd3a73bf3bd53e8de3be06a2b0232c4134 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -230,6 +230,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -237,6 +237,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public final me.samsuik.sakura.entity.merge.MergeHistory mergeHistory = new me.samsuik.sakura.entity.merge.MergeHistory(); // Sakura
public final me.samsuik.sakura.explosion.DensityCache densityCache = new me.samsuik.sakura.explosion.DensityCache();
public final me.samsuik.sakura.explosion.durable.DurableBlockManager durabilityManager = new me.samsuik.sakura.explosion.durable.DurableBlockManager();
@@ -364,7 +364,7 @@ index 1de55269a2abcdacb4c47afdfba72d6a26c22a01..9f103669880e1c40b8e12b65d5ffb30d
// Sakura start - limited get entities
public void getLimitedEntities(Entity except, AABB box, Predicate<? super Entity> predicate, List<Entity> into, int limit, int search) {
@@ -1011,6 +1012,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -1018,6 +1019,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
} else {
BlockState iblockdata2 = this.getBlockState(pos);

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Consistent Explosion Radius
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index da99328b102712f16b88e812a78fbe80418df731..730410c30b975ef0cfebb96d2e131e22b70a1109 100644
index 2e787079956c863ffd626acc77323a955e7d9871..6f1f5a03441e156b9c2cfa2c25db0aef6a7db66c 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -560,7 +560,7 @@ public class Explosion {

View File

@@ -217,18 +217,18 @@ index 50259042ebafe520342bdb1a4b7e6b9138b8acbd..adf8be12b754c3d9b16ef4a7c675dd2c
if (this.level().hasChunksAt(blockposition, blockposition1)) {
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index bf52aafe542ca735181e461d1f9cbc39b8d88220..5c95760eabf0139cce8e614a429cd6b883ad9560 100644
index bf52aafe542ca735181e461d1f9cbc39b8d88220..add0f223ca64daaf1c117a5d6885b9268f62e08a 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -77,6 +77,8 @@ public class FallingBlockEntity extends Entity {
this.isFallingBlock = true; // Sakura
this.loadChunks = world.sakuraConfig().cannons.sand.loadsChunks; // Sakura - load chunks
this.heightParity = world.sakuraConfig().cannons.mechanics.fallingBlockParity; // Sakura
+ this.physics = world.sakuraConfig().cannons.mechanics.physicsVersion; // Sakura
@@ -89,6 +89,8 @@ public class FallingBlockEntity extends Entity {
this.yo = y;
this.zo = z;
this.setStartPos(this.blockPosition());
+ this.physics = world.localConfig().config(this.blockPosition()).physicsVersion; // Sakura
+ this.eyeHeight = this.physics.isLegacy() ? 0.49f : this.eyeHeight; // Sakura
}
public FallingBlockEntity(Level world, double x, double y, double z, BlockState block) {
public static FallingBlockEntity fall(Level world, BlockPos pos, BlockState state) {
@@ -101,7 +103,11 @@ public class FallingBlockEntity extends Entity {
FallingBlockEntity entityfallingblock = new FallingBlockEntity(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, iblockdata.hasProperty(BlockStateProperties.WATERLOGGED) ? (BlockState) iblockdata.setValue(BlockStateProperties.WATERLOGGED, false) : iblockdata);
if (!CraftEventFactory.callEntityChangeBlockEvent(entityfallingblock, blockposition, iblockdata.getFluidState().createLegacyBlock())) return entityfallingblock; // CraftBukkit
@@ -346,23 +346,16 @@ index bf52aafe542ca735181e461d1f9cbc39b8d88220..5c95760eabf0139cce8e614a429cd6b8
}
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
index f25b15949f100b01e44a23832bc900d84f6cf1f1..42cdfb68d63e0144753253d92a56bbf93048de63 100644
index f25b15949f100b01e44a23832bc900d84f6cf1f1..139df4488e00fc71db6a54c4fabca775034ba8d0 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -33,6 +33,8 @@ public class PrimedTnt extends Entity implements TraceableEntity {
this.blocksBuilding = true;
this.isPrimedTNT = true; // Sakura
this.loadChunks = world.sakuraConfig().cannons.tnt.loadsChunks; // Sakura - load chunks
+ this.physics = world.sakuraConfig().cannons.mechanics.physicsVersion; // Sakura
+ this.eyeHeight = this.physics.isLegacy() ? 0.49f : this.eyeHeight; // Sakura
}
public PrimedTnt(Level world, double x, double y, double z, @Nullable LivingEntity igniter) {
@@ -52,6 +54,11 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -52,6 +52,13 @@ public class PrimedTnt extends Entity implements TraceableEntity {
case Y -> multiplyDeltaMovement(0, 1, 0);
}
// Sakura end
+ // Sakura start - physics version api
+ this.physics = world.localConfig().config(this.blockPosition()).physicsVersion;
+ this.eyeHeight = this.physics.isLegacy() ? 0.49f : this.eyeHeight;
+ if (this.physics.isLegacy()) {
+ multiplyDeltaMovement(0, 1, 0);
+ }
@@ -446,7 +439,7 @@ index f25b15949f100b01e44a23832bc900d84f6cf1f1..42cdfb68d63e0144753253d92a56bbf9
// Paper end
}
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index 730410c30b975ef0cfebb96d2e131e22b70a1109..e8d5213ec15f069b01c1ec668a6c276d3f697239 100644
index 6f1f5a03441e156b9c2cfa2c25db0aef6a7db66c..b0c90958d747e5b97acd9101764065f19f8ee793 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -69,6 +69,7 @@ public class Explosion {
@@ -461,7 +454,7 @@ index 730410c30b975ef0cfebb96d2e131e22b70a1109..e8d5213ec15f069b01c1ec668a6c276d
this.blockInteraction = destructionType;
this.damageSource = damageSource == null ? world.damageSources().explosion(this) : damageSource;
this.damageCalculator = behavior == null ? this.makeDamageCalculator(entity) : behavior;
+ this.physics = entity != null ? entity.physics() : world.sakuraConfig().cannons.mechanics.physicsVersion; // Sakura
+ this.physics = entity != null ? entity.physics() : world.localConfig().config(BlockPos.containing(x, y, z)).physicsVersion; // Sakura
}
// Paper start - optimise collisions
@@ -532,10 +525,10 @@ index 730410c30b975ef0cfebb96d2e131e22b70a1109..e8d5213ec15f069b01c1ec668a6c276d
if (data == null || !data.isExpandable() && (blockDensity == 0.0f || blockDensity == 1.0f)) {
level.densityCache.createCache(key, entity, vec3d, blockDensity);
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 9f103669880e1c40b8e12b65d5ffb30d0ca120fe..f58d7bc5839735c33f0af0fb1fd2d74de078af26 100644
index cac37ebd3a73bf3bd53e8de3be06a2b0232c4134..ebdfe421b8e3ee40350b9b717154b77c3e391a8a 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -264,6 +264,205 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -271,6 +271,205 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return this.getLimitedEntities(except, box, net.minecraft.world.entity.EntitySelector.NO_SPECTATORS, limit, search);
}
// Sakura end
@@ -742,7 +735,7 @@ index 9f103669880e1c40b8e12b65d5ffb30d0ca120fe..f58d7bc5839735c33f0af0fb1fd2d74d
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, Supplier<me.samsuik.sakura.configuration.WorldConfiguration> sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - Async-Anti-Xray - Pass executor
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
diff --git a/src/main/java/net/minecraft/world/level/block/FallingBlock.java b/src/main/java/net/minecraft/world/level/block/FallingBlock.java
index 631ac128aebcd6388482adb3b1f03673281eaf95..2c9dfbd19a13fbe628ae584bf883ec02e03ca7d5 100644
index 631ac128aebcd6388482adb3b1f03673281eaf95..b200e0ea698662d2fab45467bd26bd31c91e18d8 100644
--- a/src/main/java/net/minecraft/world/level/block/FallingBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FallingBlock.java
@@ -31,6 +31,15 @@ public class FallingBlock extends Block implements Fallable {
@@ -752,7 +745,7 @@ index 631ac128aebcd6388482adb3b1f03673281eaf95..2c9dfbd19a13fbe628ae584bf883ec02
+ // Sakura start - physics version api
+ @Override
+ public void neighborChanged(BlockState state, Level world, BlockPos pos, Block block, BlockPos fromPos, boolean notify) {
+ if (world.sakuraConfig().cannons.mechanics.physicsVersion.before(1_18_2)) {
+ if (world.localConfig().config(pos).physicsVersion.before(1_18_2)) {
+ world.scheduleTick(pos, this, this.getDelayAfterPlace());
+ }
+ }
@@ -762,7 +755,7 @@ index 631ac128aebcd6388482adb3b1f03673281eaf95..2c9dfbd19a13fbe628ae584bf883ec02
public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
if (isFree(world.getBlockState(pos.below())) && pos.getY() >= world.getMinBuildHeight()) {
diff --git a/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java b/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java
index e941a4ce35c1bcc84836d04fb97cb1e7f292ae42..8a04d2b2445b2952ae9063fb4ccbba0ef8c7382d 100644
index e941a4ce35c1bcc84836d04fb97cb1e7f292ae42..ff53e0e47da66ba99e79d1de0c04437a370577f9 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java
@@ -103,6 +103,17 @@ public class MovingPistonBlock extends BaseEntityBlock {
@@ -770,7 +763,7 @@ index e941a4ce35c1bcc84836d04fb97cb1e7f292ae42..8a04d2b2445b2952ae9063fb4ccbba0e
public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
PistonMovingBlockEntity pistonMovingBlockEntity = this.getBlockEntity(world, pos);
+ // Sakura start - physics version api
+ if (pistonMovingBlockEntity != null && world instanceof Level level && level.sakuraConfig().cannons.mechanics.physicsVersion.before(1_9_0)) {
+ if (pistonMovingBlockEntity != null && world instanceof Level level && level.localConfig().config(pos).physicsVersion.before(1_9_0)) {
+ VoxelShape shape = pistonMovingBlockEntity.getCollisionShapeFromProgress(level, pos);
+
+ if (context.isAbove(shape, pos, false)) {
@@ -784,7 +777,7 @@ index e941a4ce35c1bcc84836d04fb97cb1e7f292ae42..8a04d2b2445b2952ae9063fb4ccbba0e
}
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
index cdcf11fb9e4690d74b30fe0ade842d6574464624..56a596738799fca0eb7464062558732498b3b154 100644
index cdcf11fb9e4690d74b30fe0ade842d6574464624..0ad6230fc291008a8b34da8623b1a266d8c3b42d 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
@@ -157,6 +157,11 @@ public class PistonBaseBlock extends DirectionalBlock {
@@ -792,7 +785,7 @@ index cdcf11fb9e4690d74b30fe0ade842d6574464624..56a596738799fca0eb74640625587324
// PAIL: checkME - what happened to setTypeAndData?
// CraftBukkit end
+ // Sakura start - physics version api
+ if (world.sakuraConfig().cannons.mechanics.physicsVersion.before(1_9_0)) {
+ if (world.localConfig().config(pos).physicsVersion.before(1_9_0)) {
+ world.setBlock(pos, state.setValue(PistonBaseBlock.EXTENDED, false), 18);
+ }
+ // Sakura end
@@ -800,7 +793,7 @@ index cdcf11fb9e4690d74b30fe0ade842d6574464624..56a596738799fca0eb74640625587324
}
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonHeadBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonHeadBlock.java
index 6091e3c3adbcc92c9ca438c301a99f646e3cb549..77b177ee7723afbd289cfc80d6963744242aa9c4 100644
index 6091e3c3adbcc92c9ca438c301a99f646e3cb549..df6e859688c5b45a541b11f2046395474c083c1b 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonHeadBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonHeadBlock.java
@@ -132,6 +132,11 @@ public class PistonHeadBlock extends DirectionalBlock {
@@ -808,7 +801,7 @@ index 6091e3c3adbcc92c9ca438c301a99f646e3cb549..77b177ee7723afbd289cfc80d6963744
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
BlockState blockState = world.getBlockState(pos.relative(state.getValue(FACING).getOpposite()));
+ // Sakura start - physics version api
+ if (world instanceof Level level && level.sakuraConfig().cannons.mechanics.physicsVersion.before(1_9_0)) {
+ if (world instanceof Level level && level.localConfig().config(pos).physicsVersion.before(1_9_0)) {
+ return this.isFittingBase(state, blockState);
+ }
+ // Sakura end
@@ -820,14 +813,14 @@ index 6091e3c3adbcc92c9ca438c301a99f646e3cb549..77b177ee7723afbd289cfc80d6963744
if (state.canSurvive(world, pos)) {
world.neighborChanged(pos.relative(state.getValue(FACING).getOpposite()), sourceBlock, sourcePos);
+ // Sakura start - physics version api
+ } else if (world.sakuraConfig().cannons.mechanics.physicsVersion.before(1_9_0)) {
+ } else if (world.localConfig().config(pos).physicsVersion.before(1_9_0)) {
+ world.setBlock(pos, Blocks.AIR.defaultBlockState(), 19);
+ // Sakura end
}
}
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
index a971bb30ef8620f016a5968a9da40187ee31a3ef..aa69c005fb459965366e956eea3283ccd70a1855 100644
index a971bb30ef8620f016a5968a9da40187ee31a3ef..68bac9ea693f4457a8ced072cae85aef076eeb71 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
@@ -159,6 +159,13 @@ public class PistonMovingBlockEntity extends BlockEntity {
@@ -844,7 +837,7 @@ index a971bb30ef8620f016a5968a9da40187ee31a3ef..aa69c005fb459965366e956eea3283cc
for(AABB aABB2 : list2) {
AABB aABB3 = PistonMath.getMovementArea(moveByPositionAndProgress(pos, aABB2, blockEntity), direction, d);
AABB aABB4 = entity.getBoundingBox();
@@ -280,6 +287,137 @@ public class PistonMovingBlockEntity extends BlockEntity {
@@ -280,14 +287,154 @@ public class PistonMovingBlockEntity extends BlockEntity {
}
}
@@ -981,28 +974,30 @@ index a971bb30ef8620f016a5968a9da40187ee31a3ef..aa69c005fb459965366e956eea3283cc
+ // Sakura end
public static void tick(Level world, BlockPos pos, BlockState state, PistonMovingBlockEntity blockEntity) {
+ me.samsuik.sakura.physics.PhysicsVersion physicsVersion = world.localConfig().config(pos).physicsVersion; // Sakura
blockEntity.lastTicked = world.getGameTime();
@@ -288,6 +426,14 @@ public class PistonMovingBlockEntity extends BlockEntity {
blockEntity.progressO = blockEntity.progress;
if (blockEntity.progressO >= 1.0F) {
if (world.isClientSide && blockEntity.deathTicks < 5) {
++blockEntity.deathTicks;
} else {
+ // Sakura start - physics version api
+ if (world.sakuraConfig().cannons.mechanics.physicsVersion.isWithin(1_9_0, 1_10_0)) {
+ if (physicsVersion.isWithin(1_9_0, 1_10_0)) {
+ moveCollidedEntities(world, pos, 1.0f, blockEntity);
+ moveStuckEntities(world, pos, 1.0f, blockEntity);
+ } else if (world.sakuraConfig().cannons.mechanics.physicsVersion.before(1_9_0)) {
+ } else if (physicsVersion.before(1_9_0)) {
+ blockEntity.moveEntities(world, 0.25f);
+ }
+ // Sakura end
world.removeBlockEntity(pos);
blockEntity.setRemoved();
if (world.getBlockState(pos).is(Blocks.MOVING_PISTON)) {
@@ -308,13 +454,25 @@ public class PistonMovingBlockEntity extends BlockEntity {
@@ -308,13 +455,25 @@ public class PistonMovingBlockEntity extends BlockEntity {
}
} else {
float f = blockEntity.progress + 0.5F;
+ // Sakura start - physics version api
+ if (world.sakuraConfig().cannons.mechanics.physicsVersion.afterOrEqual(1_11_0)) {
+ if (physicsVersion.afterOrEqual(1_11_0)) {
moveCollidedEntities(world, pos, f, blockEntity);
moveStuckEntities(world, pos, f, blockEntity);
+ }
@@ -1012,10 +1007,10 @@ index a971bb30ef8620f016a5968a9da40187ee31a3ef..aa69c005fb459965366e956eea3283cc
blockEntity.progress = 1.0F;
}
+ if (world.sakuraConfig().cannons.mechanics.physicsVersion.isWithin(1_9_0, 1_10_0)) {
+ if (physicsVersion.isWithin(1_9_0, 1_10_0)) {
+ moveCollidedEntities(world, pos, f, blockEntity);
+ moveStuckEntities(world, pos, f, blockEntity);
+ } else if (blockEntity.extending && world.sakuraConfig().cannons.mechanics.physicsVersion.before(1_9_0)) {
+ } else if (blockEntity.extending && physicsVersion.before(1_9_0)) {
+ blockEntity.moveEntities(world, blockEntity.progress - blockEntity.progressO + 0.0625f);
+ }
+ // Sakura end