mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
apply pwt; fix compilation issues
This commit is contained in:
@@ -17,7 +17,7 @@ index ae609e0603a78423c4c89b7efb9c41ab8fe7aa52..5c143e3227371c701f36362e24bd3c1f
|
||||
}
|
||||
// CraftBukkit end
|
||||
diff --git a/net/minecraft/world/level/material/FlowingFluid.java b/net/minecraft/world/level/material/FlowingFluid.java
|
||||
index 1b06e44a267d2d4af844997ac0c557f30aaf9b15..fa4570dbeba4acad4da6442faebed2401fafe59d 100644
|
||||
index 1b06e44a267d2d4af844997ac0c557f30aaf9b15..abf1866c26330fc3ec61a4457a7c6966cf0f38a7 100644
|
||||
--- a/net/minecraft/world/level/material/FlowingFluid.java
|
||||
+++ b/net/minecraft/world/level/material/FlowingFluid.java
|
||||
@@ -199,6 +199,7 @@ public abstract class FlowingFluid extends Fluid {
|
||||
@@ -41,7 +41,7 @@ index 1b06e44a267d2d4af844997ac0c557f30aaf9b15..fa4570dbeba4acad4da6442faebed240
|
||||
+ BlockPos blockPos = pos.relative(direction.getOpposite());
|
||||
+ if (level.getFluidState(blockPos).is(net.minecraft.tags.FluidTags.WATER)) {
|
||||
+ Block block = level.getFluidState(pos).isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE;
|
||||
+ 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);
|
||||
+ level.setBlock(pos, block.defaultBlockState(), 3);
|
||||
+ }
|
||||
@@ -49,7 +49,7 @@ index 1b06e44a267d2d4af844997ac0c557f30aaf9b15..fa4570dbeba4acad4da6442faebed240
|
||||
+ }
|
||||
+
|
||||
+ if (isSoulSoil && level.getBlockState(blockPos).is(Blocks.BLUE_ICE)) {
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, Blocks.BASALT.defaultBlockState())) {
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, Blocks.BASALT.defaultBlockState(), 3)) {
|
||||
+ this.fizz(level, pos);
|
||||
+ }
|
||||
+ return false;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,10 +5,10 @@ Subject: [PATCH] MSPT Tracking for each world
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 11b89a625b942f5f2f882c54dbfc08c16e983425..fc9de137ed1681afd1ef51391cf8f30fd4c61c4b 100644
|
||||
index ef2cf6d9ca57266bb0466ca1aa5d2066349f9954..c4ae883af4337e04d0944c603f298ee1576cb3d2 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1684,7 +1684,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1674,7 +1674,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
// DivineMC start - Parallel world ticking
|
||||
private void tickLevel(ServerLevel serverLevel, BooleanSupplier hasTimeLeft) {
|
||||
try {
|
||||
@@ -25,10 +25,10 @@ index 11b89a625b942f5f2f882c54dbfc08c16e983425..fc9de137ed1681afd1ef51391cf8f30f
|
||||
CrashReport crashReport = CrashReport.forThrowable(levelTickingException, "Exception ticking world");
|
||||
serverLevel.fillReportDetails(crashReport);
|
||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||
index e034d9f903728cdf7356629694c9f528ba5ebae3..561066a2cf769e13ef3cea0881f7a2010ecbf2ec 100644
|
||||
index 857439f7b59549cff75e318fdf9c1effe83c7e17..d93014a396c13fed0e86dfadcb5436773efaa2a0 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -575,6 +575,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -568,6 +568,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
}
|
||||
// Paper end - chunk tick iteration
|
||||
|
||||
@@ -20,10 +20,10 @@ index 4535858701b2bb232b9d2feb2af6551526232ddc..aa4dd7517e8be167aef1eaf7aa907e3c
|
||||
if (var4 instanceof ReportedException reportedException && reportedException.getCause() instanceof OutOfMemoryError) {
|
||||
throw makeReportedException(var4, packet, processor);
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 804de864da13ae0be6a1caee88e95a19e35d08c0..5a0c8791495aa522e511918ad0a24d9bbe6b5877 100644
|
||||
index c4ae883af4337e04d0944c603f298ee1576cb3d2..3a82ce898c38c5d3d971178e2614aed638e03132 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1694,6 +1694,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1683,6 +1683,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
serverLevel.tickTimes10s.add(this.tickCount, j);
|
||||
serverLevel.tickTimes60s.add(this.tickCount, j);
|
||||
// DivineMC end - MSPT Tracking for each world
|
||||
@@ -35,10 +35,10 @@ index 804de864da13ae0be6a1caee88e95a19e35d08c0..5a0c8791495aa522e511918ad0a24d9b
|
||||
CrashReport crashReport = CrashReport.forThrowable(levelTickingException, "Exception ticking world");
|
||||
serverLevel.fillReportDetails(crashReport);
|
||||
diff --git a/net/minecraft/world/level/block/ShulkerBoxBlock.java b/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
||||
index cdf835ff107bc1eadde706d69384e687626fce70..c04c66668395fa9167e027131daf75c0e9ee6eff 100644
|
||||
index 49bac7af90b0a7c490141be6357563447783c6ca..941e2f04a7fd5472ad38ede08d81657604d9f2b3 100644
|
||||
--- a/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
||||
+++ b/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
||||
@@ -234,7 +234,17 @@ public class ShulkerBoxBlock extends BaseEntityBlock {
|
||||
@@ -183,7 +183,17 @@ public class ShulkerBoxBlock extends BaseEntityBlock {
|
||||
|
||||
@Override
|
||||
protected int getAnalogOutputSignal(BlockState blockState, Level level, BlockPos pos) {
|
||||
@@ -58,10 +58,10 @@ index cdf835ff107bc1eadde706d69384e687626fce70..c04c66668395fa9167e027131daf75c0
|
||||
|
||||
public static Block getBlockByColor(@Nullable DyeColor color) {
|
||||
diff --git a/net/minecraft/world/level/redstone/NeighborUpdater.java b/net/minecraft/world/level/redstone/NeighborUpdater.java
|
||||
index 26c15c60d358273a3b369c286771c81d6f0979dd..94fde31891e9f549ca356955913385cbaad02dca 100644
|
||||
index 332b33a004ab11150cca0cc2cefc26d0286648f5..e6dce5f8bc87a2d0c7985959e3c0408f77b36f5b 100644
|
||||
--- a/net/minecraft/world/level/redstone/NeighborUpdater.java
|
||||
+++ b/net/minecraft/world/level/redstone/NeighborUpdater.java
|
||||
@@ -63,9 +63,19 @@ public interface NeighborUpdater {
|
||||
@@ -60,9 +60,19 @@ public interface NeighborUpdater {
|
||||
state.handleNeighborChanged(level, pos, neighborBlock, orientation, movedByPiston);
|
||||
// Spigot start
|
||||
} catch (StackOverflowError ex) {
|
||||
@@ -70,7 +70,7 @@ index 26c15c60d358273a3b369c286771c81d6f0979dd..94fde31891e9f549ca356955913385cb
|
||||
+ throw new org.bxteam.divinemc.util.exception.UpdateSuppressorException(pos, neighborBlock);
|
||||
+ }
|
||||
+ // DivineMC end - Catch update suppressors
|
||||
level.lastPhysicsProblem = new BlockPos(pos);
|
||||
level.lastPhysicsProblem = pos.immutable();
|
||||
// Spigot end
|
||||
} catch (Throwable var9) {
|
||||
+ // DivineMC start - Catch update suppressors
|
||||
@@ -222,7 +222,7 @@ index 69cdd304d255d52c9b7dc9b6a33ffdb630b79abe..c153e79ebe1f2338f0d0ca6b45b39279
|
||||
+ // DivineMC end - Parallel world ticking
|
||||
}
|
||||
diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
index d7398b1ecf2660c29fb7d106b48fe02d3736603e..124715b53090085fc0a9f50bb2df196d31d89bed 100644
|
||||
index a9ec83b5bcb329bf3d2f3fb0e502685a37f9dcbc..adf526bcb5b4df3b798a8b80ad11b7b2c30775d7 100644
|
||||
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
@@ -28,6 +28,7 @@ import java.util.logging.Level;
|
||||
@@ -245,12 +245,12 @@ index d7398b1ecf2660c29fb7d106b48fe02d3736603e..124715b53090085fc0a9f50bb2df196d
|
||||
+ // DivineMC end - Parallel world ticking
|
||||
throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously.");
|
||||
} else if (!event.isAsynchronous() && !this.server.isPrimaryThread() && !this.server.isStopping()) {
|
||||
throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously.");
|
||||
// DivineMC start - Multithreaded Tracker
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index bc2522968205d0c701a2fa23f29565a500881492..312018206729b623a7c854af1c11a2d0bc888372 100644
|
||||
index 7ce39901cb1bd41a214ed4444d2072656943fa0f..c3ea717868c2064ea5ff23a79cbbe4cc81557c86 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -446,7 +446,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
@@ -447,7 +447,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
|
||||
@Override
|
||||
public boolean unloadChunkRequest(int x, int z) {
|
||||
@@ -263,9 +263,9 @@ index bc2522968205d0c701a2fa23f29565a500881492..312018206729b623a7c854af1c11a2d0
|
||||
+ }
|
||||
+ // DivineMC end - Parallel world ticking
|
||||
if (this.isChunkLoaded(x, z)) {
|
||||
this.world.getChunkSource().removeRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 1, Unit.INSTANCE);
|
||||
this.world.getChunkSource().removeTicketWithRadius(TicketType.PLUGIN, new ChunkPos(x, z), 1);
|
||||
}
|
||||
@@ -471,6 +477,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
@@ -472,6 +478,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
|
||||
@Override
|
||||
public boolean refreshChunk(int x, int z) {
|
||||
@@ -273,7 +273,7 @@ index bc2522968205d0c701a2fa23f29565a500881492..312018206729b623a7c854af1c11a2d0
|
||||
ChunkHolder playerChunk = this.world.getChunkSource().chunkMap.getVisibleChunkIfPresent(ChunkPos.asLong(x, z));
|
||||
if (playerChunk == null) return false;
|
||||
|
||||
@@ -521,7 +528,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
@@ -522,7 +529,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
|
||||
@Override
|
||||
public boolean loadChunk(int x, int z, boolean generate) {
|
||||
@@ -288,7 +288,7 @@ index bc2522968205d0c701a2fa23f29565a500881492..312018206729b623a7c854af1c11a2d0
|
||||
warnUnsafeChunk("loading a faraway chunk", x, z); // Paper
|
||||
ChunkAccess chunk = this.world.getChunkSource().getChunk(x, z, generate || isChunkGenerated(x, z) ? ChunkStatus.FULL : ChunkStatus.EMPTY, true); // Paper
|
||||
|
||||
@@ -749,6 +762,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
@@ -750,6 +763,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
|
||||
@Override
|
||||
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
|
||||
@@ -296,7 +296,7 @@ index bc2522968205d0c701a2fa23f29565a500881492..312018206729b623a7c854af1c11a2d0
|
||||
this.world.captureTreeGeneration = true;
|
||||
this.world.captureBlockStates = true;
|
||||
boolean grownTree = this.generateTree(loc, type);
|
||||
@@ -864,6 +878,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
@@ -865,6 +879,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
}
|
||||
public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source, Consumer<net.minecraft.world.level.ServerExplosion> configurator) {
|
||||
// Paper end - expand explosion API
|
||||
@@ -304,7 +304,7 @@ index bc2522968205d0c701a2fa23f29565a500881492..312018206729b623a7c854af1c11a2d0
|
||||
net.minecraft.world.level.Level.ExplosionInteraction explosionType;
|
||||
if (!breakBlocks) {
|
||||
explosionType = net.minecraft.world.level.Level.ExplosionInteraction.NONE; // Don't break blocks
|
||||
@@ -955,6 +970,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
@@ -956,6 +971,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
|
||||
@Override
|
||||
public int getHighestBlockYAt(int x, int z, org.bukkit.HeightMap heightMap) {
|
||||
@@ -312,7 +312,7 @@ index bc2522968205d0c701a2fa23f29565a500881492..312018206729b623a7c854af1c11a2d0
|
||||
warnUnsafeChunk("getting a faraway chunk", x >> 4, z >> 4); // Paper
|
||||
// Transient load for this tick
|
||||
return this.world.getChunk(x >> 4, z >> 4).getHeight(CraftHeightMap.toNMS(heightMap), x, z);
|
||||
@@ -985,6 +1001,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
@@ -986,6 +1002,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
@Override
|
||||
public void setBiome(int x, int y, int z, Holder<net.minecraft.world.level.biome.Biome> bb) {
|
||||
BlockPos pos = new BlockPos(x, 0, z);
|
||||
@@ -320,7 +320,7 @@ index bc2522968205d0c701a2fa23f29565a500881492..312018206729b623a7c854af1c11a2d0
|
||||
if (this.world.hasChunkAt(pos)) {
|
||||
net.minecraft.world.level.chunk.LevelChunk chunk = this.world.getChunkAt(pos);
|
||||
|
||||
@@ -2288,6 +2305,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
@@ -2294,6 +2311,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
|
||||
@Override
|
||||
public void sendGameEvent(Entity sourceEntity, org.bukkit.GameEvent gameEvent, Vector position) {
|
||||
@@ -329,7 +329,7 @@ index bc2522968205d0c701a2fa23f29565a500881492..312018206729b623a7c854af1c11a2d0
|
||||
}
|
||||
// Paper end
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
index 5cb69d0b822e11a99a96aef4f59986d083b079f4..0e47184336f63123211e24a966908a16aa27d6c6 100644
|
||||
index e9ca19c8668d3028f9453f478b1853baa24b47b4..01dd87b5bb0695ea6a1ba386a759e281488d7bdd 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
@@ -75,6 +75,11 @@ public class CraftBlock implements Block {
|
||||
@@ -344,31 +344,31 @@ index 5cb69d0b822e11a99a96aef4f59986d083b079f4..0e47184336f63123211e24a966908a16
|
||||
return this.world.getBlockState(this.position);
|
||||
}
|
||||
|
||||
@@ -157,6 +162,11 @@ public class CraftBlock implements Block {
|
||||
@@ -155,6 +160,11 @@ public class CraftBlock implements Block {
|
||||
}
|
||||
|
||||
private void setData(final byte data, int flag) {
|
||||
private void setData(final byte data, int flags) {
|
||||
+ // DivineMC start - Parallel world ticking
|
||||
+ if (org.bxteam.divinemc.DivineConfig.enableParallelWorldTicking && world instanceof ServerLevel serverWorld) {
|
||||
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(serverWorld, position, "Cannot modify world asynchronously");
|
||||
+ }
|
||||
+ // DivineMC end - Parallel world ticking
|
||||
this.world.setBlock(this.position, CraftMagicNumbers.getBlock(this.getType(), data), flag);
|
||||
this.world.setBlock(this.position, CraftMagicNumbers.getBlock(this.getType(), data), flags);
|
||||
}
|
||||
|
||||
@@ -198,6 +208,11 @@ public class CraftBlock implements Block {
|
||||
@@ -196,6 +206,11 @@ public class CraftBlock implements Block {
|
||||
}
|
||||
|
||||
public static boolean setTypeAndData(LevelAccessor world, BlockPos position, net.minecraft.world.level.block.state.BlockState old, net.minecraft.world.level.block.state.BlockState blockData, boolean applyPhysics) {
|
||||
public static boolean setBlockState(LevelAccessor world, BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState, boolean applyPhysics) {
|
||||
+ // DivineMC start - Parallel world ticking
|
||||
+ if (org.bxteam.divinemc.DivineConfig.enableParallelWorldTicking && world instanceof ServerLevel serverWorld) {
|
||||
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(serverWorld, position, "Cannot modify world asynchronously");
|
||||
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(serverWorld, pos, "Cannot modify world asynchronously");
|
||||
+ }
|
||||
+ // DivineMC end - Parallel world ticking
|
||||
// SPIGOT-611: need to do this to prevent glitchiness. Easier to handle this here (like /setblock) than to fix weirdness in tile entity cleanup
|
||||
if (old.hasBlockEntity() && blockData.getBlock() != old.getBlock()) { // SPIGOT-3725 remove old tile entity if block changes
|
||||
// SPIGOT-611: need to do this to prevent glitchiness. Easier to handle this here (like /setblock) than to fix weirdness in block entity cleanup
|
||||
if (oldState.hasBlockEntity() && newState.getBlock() != oldState.getBlock()) { // SPIGOT-3725 remove old block entity if block changes
|
||||
// SPIGOT-4612: faster - just clear tile
|
||||
@@ -343,18 +358,33 @@ public class CraftBlock implements Block {
|
||||
@@ -344,18 +359,33 @@ public class CraftBlock implements Block {
|
||||
|
||||
@Override
|
||||
public Biome getBiome() {
|
||||
@@ -402,7 +402,7 @@ index 5cb69d0b822e11a99a96aef4f59986d083b079f4..0e47184336f63123211e24a966908a16
|
||||
this.getWorld().setBiome(this.getX(), this.getY(), this.getZ(), bio);
|
||||
}
|
||||
|
||||
@@ -402,6 +432,11 @@ public class CraftBlock implements Block {
|
||||
@@ -403,6 +433,11 @@ public class CraftBlock implements Block {
|
||||
|
||||
@Override
|
||||
public boolean isBlockFaceIndirectlyPowered(BlockFace face) {
|
||||
@@ -414,7 +414,7 @@ index 5cb69d0b822e11a99a96aef4f59986d083b079f4..0e47184336f63123211e24a966908a16
|
||||
int power = this.world.getMinecraftWorld().getSignal(this.position, CraftBlock.blockFaceToNotch(face));
|
||||
|
||||
Block relative = this.getRelative(face);
|
||||
@@ -414,6 +449,11 @@ public class CraftBlock implements Block {
|
||||
@@ -415,6 +450,11 @@ public class CraftBlock implements Block {
|
||||
|
||||
@Override
|
||||
public int getBlockPower(BlockFace face) {
|
||||
@@ -426,7 +426,7 @@ index 5cb69d0b822e11a99a96aef4f59986d083b079f4..0e47184336f63123211e24a966908a16
|
||||
int power = 0;
|
||||
net.minecraft.world.level.Level world = this.world.getMinecraftWorld();
|
||||
int x = this.getX();
|
||||
@@ -484,6 +524,11 @@ public class CraftBlock implements Block {
|
||||
@@ -483,6 +523,11 @@ public class CraftBlock implements Block {
|
||||
|
||||
@Override
|
||||
public boolean breakNaturally() {
|
||||
@@ -438,7 +438,7 @@ index 5cb69d0b822e11a99a96aef4f59986d083b079f4..0e47184336f63123211e24a966908a16
|
||||
return this.breakNaturally(null);
|
||||
}
|
||||
|
||||
@@ -543,6 +588,11 @@ public class CraftBlock implements Block {
|
||||
@@ -542,6 +587,11 @@ public class CraftBlock implements Block {
|
||||
|
||||
@Override
|
||||
public boolean applyBoneMeal(BlockFace face) {
|
||||
@@ -450,17 +450,17 @@ index 5cb69d0b822e11a99a96aef4f59986d083b079f4..0e47184336f63123211e24a966908a16
|
||||
Direction direction = CraftBlock.blockFaceToNotch(face);
|
||||
BlockFertilizeEvent event = null;
|
||||
ServerLevel world = this.getCraftWorld().getHandle();
|
||||
@@ -554,8 +604,10 @@ public class CraftBlock implements Block {
|
||||
@@ -553,8 +603,10 @@ public class CraftBlock implements Block {
|
||||
world.captureTreeGeneration = false;
|
||||
|
||||
if (world.capturedBlockStates.size() > 0) {
|
||||
if (!world.capturedBlockStates.isEmpty()) {
|
||||
- TreeType treeType = SaplingBlock.treeType;
|
||||
- SaplingBlock.treeType = null;
|
||||
+ // DivineMC start - Parallel world ticking
|
||||
+ TreeType treeType = SaplingBlock.getTreeTypeTL();
|
||||
+ SaplingBlock.setTreeTypeTL(null);
|
||||
+ // DivineMC end - Parallel world ticking
|
||||
List<BlockState> blocks = new ArrayList<>(world.capturedBlockStates.values());
|
||||
List<BlockState> states = new ArrayList<>(world.capturedBlockStates.values());
|
||||
world.capturedBlockStates.clear();
|
||||
StructureGrowEvent structureEvent = null;
|
||||
@@ -644,6 +696,11 @@ public class CraftBlock implements Block {
|
||||
@@ -500,7 +500,7 @@ index 5cb69d0b822e11a99a96aef4f59986d083b079f4..0e47184336f63123211e24a966908a16
|
||||
this.getNMS().tick(level, this.position, level.random);
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
|
||||
index 768d3f93da2522d467183654260a8bd8653588b1..dd3c9e214a59d20c2b5e8556951687e2aba2d116 100644
|
||||
index 3422970353dcd886934b9ee906467769d39abbde..cb60c1b09f06872c07d05b04b7bacc5921fea78d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
|
||||
@@ -26,6 +26,25 @@ public abstract class CraftBlockEntityState<T extends BlockEntity> extends Craft
|
||||
@@ -527,8 +527,8 @@ index 768d3f93da2522d467183654260a8bd8653588b1..dd3c9e214a59d20c2b5e8556951687e2
|
||||
+ }
|
||||
+ // DivineMC end - Parallel world ticking
|
||||
|
||||
public CraftBlockEntityState(World world, T tileEntity) {
|
||||
super(world, tileEntity.getBlockPos(), tileEntity.getBlockState());
|
||||
public CraftBlockEntityState(World world, T blockEntity) {
|
||||
super(world, blockEntity.getBlockPos(), blockEntity.getBlockState());
|
||||
@@ -34,8 +53,10 @@ public abstract class CraftBlockEntityState<T extends BlockEntity> extends Craft
|
||||
|
||||
try { // Paper - Show blockstate location if we failed to read it
|
||||
@@ -539,14 +539,14 @@ index 768d3f93da2522d467183654260a8bd8653588b1..dd3c9e214a59d20c2b5e8556951687e2
|
||||
+ this.snapshotDisabled = getDisableSnapshotTL();
|
||||
+ if (snapshotDisabled) {
|
||||
+ // DivineMC end - Parallel world ticking
|
||||
this.snapshot = this.tileEntity;
|
||||
this.snapshot = this.blockEntity;
|
||||
} else {
|
||||
this.snapshot = this.createSnapshot(tileEntity);
|
||||
this.snapshot = this.createSnapshot(blockEntity);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
||||
index fa63a6cfcfcc4eee4503a82d85333c139c8c8b2b..cddb460892f1756faa4b58ae53406058acd9803d 100644
|
||||
index c0a7659776a9f0fb82bb8563acbf3286b318fe03..d4ffcf6a96a66f4482af440d1b89aa8ccdd0fd9b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
||||
@@ -215,6 +215,12 @@ public class CraftBlockState implements BlockState {
|
||||
@@ -217,6 +217,12 @@ public class CraftBlockState implements BlockState {
|
||||
LevelAccessor access = this.getWorldHandle();
|
||||
CraftBlock block = this.getBlock();
|
||||
|
||||
@@ -559,7 +559,7 @@ index fa63a6cfcfcc4eee4503a82d85333c139c8c8b2b..cddb460892f1756faa4b58ae53406058
|
||||
if (block.getType() != this.getType()) {
|
||||
if (!force) {
|
||||
return false;
|
||||
@@ -350,6 +356,7 @@ public class CraftBlockState implements BlockState {
|
||||
@@ -365,6 +371,7 @@ public class CraftBlockState implements BlockState {
|
||||
|
||||
@Override
|
||||
public java.util.Collection<org.bukkit.inventory.ItemStack> getDrops(org.bukkit.inventory.ItemStack item, org.bukkit.entity.Entity entity) {
|
||||
@@ -568,13 +568,13 @@ index fa63a6cfcfcc4eee4503a82d85333c139c8c8b2b..cddb460892f1756faa4b58ae53406058
|
||||
net.minecraft.world.item.ItemStack nms = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(item);
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
|
||||
index 56453454cbd4b9e9270fc833f8ab38d5fa7a3763..c3cc5012cf460f57495d8867f198007676bae5bf 100644
|
||||
index 2338e7c115037430cefae26a571ded71f77983c4..6d5af7f72158e9e4abbfb6ae650833a66ea7a934 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
|
||||
@@ -249,8 +249,10 @@ public final class CraftBlockStates {
|
||||
net.minecraft.world.level.block.state.BlockState blockData = craftBlock.getNMS();
|
||||
BlockEntity tileEntity = craftBlock.getHandle().getBlockEntity(blockPosition);
|
||||
// Paper start - block state snapshots
|
||||
@@ -195,14 +195,16 @@ public final class CraftBlockStates {
|
||||
BlockPos pos = craftBlock.getPosition();
|
||||
net.minecraft.world.level.block.state.BlockState state = craftBlock.getNMS();
|
||||
BlockEntity blockEntity = craftBlock.getHandle().getBlockEntity(pos);
|
||||
- boolean prev = CraftBlockEntityState.DISABLE_SNAPSHOT;
|
||||
- CraftBlockEntityState.DISABLE_SNAPSHOT = !useSnapshot;
|
||||
+ // DivineMC start - Parallel world ticking
|
||||
@@ -582,69 +582,15 @@ index 56453454cbd4b9e9270fc833f8ab38d5fa7a3763..c3cc5012cf460f57495d8867f1980076
|
||||
+ CraftBlockEntityState.setDisableSnapshotTL(!useSnapshot);
|
||||
+ // DivineMC end - Parallel world ticking
|
||||
try {
|
||||
// Paper end
|
||||
CraftBlockState blockState = CraftBlockStates.getBlockState(world, blockPosition, blockData, tileEntity);
|
||||
@@ -258,7 +260,7 @@ public final class CraftBlockStates {
|
||||
CraftBlockState blockState = CraftBlockStates.getBlockState(world, pos, state, blockEntity);
|
||||
blockState.setWorldHandle(craftBlock.getHandle()); // Inject the block's generator access
|
||||
return blockState;
|
||||
// Paper start
|
||||
} finally {
|
||||
- CraftBlockEntityState.DISABLE_SNAPSHOT = prev;
|
||||
+ CraftBlockEntityState.setDisableSnapshotTL(prev); // DivineMC - Parallel world ticking
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
index 4df143dfa4c01dc70e496ec8dc44fdde00ab40c6..59ee059f8d2d96b5e5ae507f209d267da24c9fa1 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
@@ -961,6 +961,26 @@ public class CraftEventFactory {
|
||||
}
|
||||
|
||||
public static BlockPos sourceBlockOverride = null; // SPIGOT-7068: Add source block override, not the most elegant way but better than passing down a BlockPosition up to five methods deep.
|
||||
+ // DivineMC start - Parallel world ticking
|
||||
+ public static final ThreadLocal<BlockPos> sourceBlockOverrideTL = new ThreadLocal<>();
|
||||
+
|
||||
+ public static BlockPos getSourceBlockOverrideTL() {
|
||||
+ BlockPos sourceBlockOverrideRTCopy;
|
||||
+ if (org.bxteam.divinemc.DivineConfig.enableParallelWorldTicking && (sourceBlockOverrideRTCopy = sourceBlockOverrideTL.get()) != null) return sourceBlockOverrideRTCopy;
|
||||
+
|
||||
+ synchronized (CraftEventFactory.class) {
|
||||
+ return sourceBlockOverride;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void setSourceBlockOverrideTL(BlockPos value) {
|
||||
+ if (org.bxteam.divinemc.DivineConfig.enableParallelWorldTicking) sourceBlockOverrideTL.set(value);
|
||||
+
|
||||
+ synchronized (CraftEventFactory.class) {
|
||||
+ sourceBlockOverride = value;
|
||||
+ }
|
||||
+ }
|
||||
+ // DivineMC end - Parallel world ticking
|
||||
|
||||
public static boolean handleBlockSpreadEvent(LevelAccessor world, BlockPos source, BlockPos target, net.minecraft.world.level.block.state.BlockState block, int flag) {
|
||||
// Suppress during worldgen
|
||||
@@ -972,7 +992,10 @@ public class CraftEventFactory {
|
||||
CraftBlockState state = CraftBlockStates.getBlockState(world, target, flag);
|
||||
state.setData(block);
|
||||
|
||||
- BlockSpreadEvent event = new BlockSpreadEvent(state.getBlock(), CraftBlock.at(world, CraftEventFactory.sourceBlockOverride != null ? CraftEventFactory.sourceBlockOverride : source), state);
|
||||
+ // DivineMC start - Parallel world ticking
|
||||
+ final BlockPos sourceBlockOverrideRTSnap = getSourceBlockOverrideTL();
|
||||
+ BlockSpreadEvent event = new BlockSpreadEvent(state.getBlock(), CraftBlock.at(world, sourceBlockOverrideRTSnap != null ? sourceBlockOverrideRTSnap : source), state);
|
||||
+ // DivineMC end - Parallel world ticking
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
@@ -2245,7 +2268,7 @@ public class CraftEventFactory {
|
||||
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemStack.copyWithCount(1));
|
||||
|
||||
org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), CraftVector.toBukkit(to));
|
||||
- if (!net.minecraft.world.level.block.DispenserBlock.eventFired) {
|
||||
+ if (!net.minecraft.world.level.block.DispenserBlock.getEventFiredTL()) { // DivineMC - Parallel world ticking
|
||||
if (!event.callEvent()) {
|
||||
return itemStack;
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncTask.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncTask.java
|
||||
index e4e2e42d0ca25df7fe9f2dd4275610e45fcb2c84..8d0816dcc4159b62e5bbb03e3897b255feb961e6 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncTask.java
|
||||
@@ -45,7 +45,7 @@ public final class GeneralUtils {
|
||||
for (StructureTemplate.JigsawBlockInfo structureBlockInfo : list) {
|
||||
int key = 0;
|
||||
if (structureBlockInfo.info().nbt() != null) {
|
||||
key = getIntMicroOptimised(structureBlockInfo.info().nbt(), "selection_priority");
|
||||
key = structureBlockInfo.info().nbt().getIntOr("selection_priority", 0);
|
||||
}
|
||||
|
||||
buckets.computeIfAbsent(key, k -> new ArrayList<>()).add(structureBlockInfo);
|
||||
@@ -73,12 +73,8 @@ public final class GeneralUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static int getIntMicroOptimised(@NotNull CompoundTag tag, String key) {
|
||||
return tag.get(key) instanceof NumericTag numericTag ? numericTag.getAsInt() : 0;
|
||||
}
|
||||
|
||||
public static @NotNull String getStringMicroOptimised(@NotNull CompoundTag tag, String key) {
|
||||
return tag.get(key) instanceof StringTag stringTag ? stringTag.getAsString() : "";
|
||||
return tag.get(key) instanceof StringTag stringTag ? stringTag.value() : "";
|
||||
}
|
||||
|
||||
public static <T> void copyAll(@NotNull List<T> src, List<T> dest) {
|
||||
|
||||
Reference in New Issue
Block a user