3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00

Improve physics code

Dieser Commit ist enthalten in:
md_5 2020-07-07 09:35:47 +10:00
Ursprung 7a9e4f7aeb
Commit 2f18108123
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: E8E901AC7C617C11
3 geänderte Dateien mit 11 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -191,7 +191,7 @@
+ 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.

Datei anzeigen

@ -173,7 +173,7 @@
+ // CraftBukkit start
+ if (!this.captureBlockStates) { // Don't notify clients or update physics while capturing blockstates
+ // Modularize client and physic updates
+ notifyAndUpdatePhysics(blockposition, chunk, iblockdata1, iblockdata, iblockdata2, i);
+ notifyAndUpdatePhysics(blockposition, chunk, iblockdata1, iblockdata, iblockdata2, i, j);
+ }
+ // CraftBukkit end
@ -183,7 +183,7 @@
}
+ // 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 iblockdata1 = oldBlock;
+ IBlockData iblockdata2 = actualBlock;
@ -196,18 +196,18 @@
+ this.notify(blockposition, iblockdata1, iblockdata, i);
+ }
+
+ if (!this.isClientSide && (i & 1) != 0) {
+ if ((i & 1) != 0) {
+ this.update(blockposition, iblockdata1.getBlock());
+ if (iblockdata.isComplexRedstone()) {
+ if (!this.isClientSide && iblockdata.isComplexRedstone()) {
+ this.updateAdjacentComparators(blockposition, newBlock.getBlock());
+ }
+ }
+
+ if ((i & 16) == 0) {
+ int j = i & -2;
+ if ((i & 16) == 0 && j > 0) {
+ int k = i & -34;
+
+ // 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();
+ if (world != null) {
+ BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftBlockData.fromData(iblockdata));
@ -218,8 +218,8 @@
+ }
+ }
+ // CraftBukkit end
+ iblockdata.a(this, blockposition, j);
+ iblockdata.b(this, blockposition, j);
+ iblockdata.a((GeneratorAccess) this, blockposition, k, j - 1);
+ iblockdata.b(this, blockposition, k, j - 1);
+ }
+
+ this.a(blockposition, iblockdata1, iblockdata2);

Datei anzeigen

@ -762,7 +762,7 @@ public class CraftWorld implements World {
int flag = ((CraftBlockState) blockstate).getFlag();
delegate.setBlockData(blockstate.getX(), blockstate.getY(), blockstate.getZ(), blockstate.getBlockData());
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();
return true;