Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 12:30:06 +01:00
Improve physics code
Dieser Commit ist enthalten in:
Ursprung
7a9e4f7aeb
Commit
2f18108123
@ -191,7 +191,7 @@
|
|||||||
+ block.getBlock().onPlace(block, world, newblockposition, oldBlock, true);
|
+ block.getBlock().onPlace(block, world, newblockposition, oldBlock, true);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getType(newblockposition), updateFlag); // send null chunk as chunk.k() returns false by this point
|
+ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getType(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ // Special case juke boxes as they update their tile entity. Copied from ItemRecord.
|
+ // Special case juke boxes as they update their tile entity. Copied from ItemRecord.
|
||||||
|
@ -173,7 +173,7 @@
|
|||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ if (!this.captureBlockStates) { // Don't notify clients or update physics while capturing blockstates
|
+ if (!this.captureBlockStates) { // Don't notify clients or update physics while capturing blockstates
|
||||||
+ // Modularize client and physic updates
|
+ // Modularize client and physic updates
|
||||||
+ notifyAndUpdatePhysics(blockposition, chunk, iblockdata1, iblockdata, iblockdata2, i);
|
+ notifyAndUpdatePhysics(blockposition, chunk, iblockdata1, iblockdata, iblockdata2, i, j);
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
|
||||||
@ -183,7 +183,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
+ // CraftBukkit start - Split off from above in order to directly send client and physic updates
|
+ // CraftBukkit start - Split off from above in order to directly send client and physic updates
|
||||||
+ public void notifyAndUpdatePhysics(BlockPosition blockposition, Chunk chunk, IBlockData oldBlock, IBlockData newBlock, IBlockData actualBlock, int i) {
|
+ public void notifyAndUpdatePhysics(BlockPosition blockposition, Chunk chunk, IBlockData oldBlock, IBlockData newBlock, IBlockData actualBlock, int i, int j) {
|
||||||
+ IBlockData iblockdata = newBlock;
|
+ IBlockData iblockdata = newBlock;
|
||||||
+ IBlockData iblockdata1 = oldBlock;
|
+ IBlockData iblockdata1 = oldBlock;
|
||||||
+ IBlockData iblockdata2 = actualBlock;
|
+ IBlockData iblockdata2 = actualBlock;
|
||||||
@ -196,18 +196,18 @@
|
|||||||
+ this.notify(blockposition, iblockdata1, iblockdata, i);
|
+ this.notify(blockposition, iblockdata1, iblockdata, i);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ if (!this.isClientSide && (i & 1) != 0) {
|
+ if ((i & 1) != 0) {
|
||||||
+ this.update(blockposition, iblockdata1.getBlock());
|
+ this.update(blockposition, iblockdata1.getBlock());
|
||||||
+ if (iblockdata.isComplexRedstone()) {
|
+ if (!this.isClientSide && iblockdata.isComplexRedstone()) {
|
||||||
+ this.updateAdjacentComparators(blockposition, newBlock.getBlock());
|
+ this.updateAdjacentComparators(blockposition, newBlock.getBlock());
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ if ((i & 16) == 0) {
|
+ if ((i & 16) == 0 && j > 0) {
|
||||||
+ int j = i & -2;
|
+ int k = i & -34;
|
||||||
+
|
+
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ iblockdata1.b(this, blockposition, j); // Don't call an event for the old block to limit event spam
|
+ iblockdata1.b(this, blockposition, k, j - 1); // Don't call an event for the old block to limit event spam
|
||||||
+ CraftWorld world = ((WorldServer) this).getWorld();
|
+ CraftWorld world = ((WorldServer) this).getWorld();
|
||||||
+ if (world != null) {
|
+ if (world != null) {
|
||||||
+ BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftBlockData.fromData(iblockdata));
|
+ BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftBlockData.fromData(iblockdata));
|
||||||
@ -218,8 +218,8 @@
|
|||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+ iblockdata.a(this, blockposition, j);
|
+ iblockdata.a((GeneratorAccess) this, blockposition, k, j - 1);
|
||||||
+ iblockdata.b(this, blockposition, j);
|
+ iblockdata.b(this, blockposition, k, j - 1);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ this.a(blockposition, iblockdata1, iblockdata2);
|
+ this.a(blockposition, iblockdata1, iblockdata2);
|
||||||
|
@ -762,7 +762,7 @@ public class CraftWorld implements World {
|
|||||||
int flag = ((CraftBlockState) blockstate).getFlag();
|
int flag = ((CraftBlockState) blockstate).getFlag();
|
||||||
delegate.setBlockData(blockstate.getX(), blockstate.getY(), blockstate.getZ(), blockstate.getBlockData());
|
delegate.setBlockData(blockstate.getX(), blockstate.getY(), blockstate.getZ(), blockstate.getBlockData());
|
||||||
net.minecraft.server.IBlockData newBlock = world.getType(position);
|
net.minecraft.server.IBlockData newBlock = world.getType(position);
|
||||||
world.notifyAndUpdatePhysics(position, null, oldBlock, newBlock, newBlock, flag);
|
world.notifyAndUpdatePhysics(position, null, oldBlock, newBlock, newBlock, flag, 512);
|
||||||
}
|
}
|
||||||
world.capturedBlockStates.clear();
|
world.capturedBlockStates.clear();
|
||||||
return true;
|
return true;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren