Paper/CraftBukkit-Patches/0063-More-Efficient-GetCubes.patch

87 lines
3.8 KiB
Diff
Raw Normal View History

2015-04-09 05:41:04 +02:00
From 1c807b738a7524dd87695686f3be58ca1a987cb8 Mon Sep 17 00:00:00 2001
2014-11-28 02:17:45 +01:00
From: md_5 <md_5@live.com.au>
Date: Tue, 11 Jun 2013 12:17:37 +1000
Subject: [PATCH] More Efficient GetCubes
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
2015-04-09 05:18:56 +02:00
index c1789a0..c7ef0c5 100644
2014-11-28 02:17:45 +01:00
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
2015-03-16 11:19:21 +01:00
@@ -1104,28 +1104,56 @@ public abstract class World implements IBlockAccess {
2015-02-28 12:36:22 +01:00
IBlockData iblockdata = Blocks.STONE.getBlockData();
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
2014-11-28 02:17:45 +01:00
- for (int k1 = i; k1 < j; ++k1) {
- for (int l1 = i1; l1 < j1; ++l1) {
2015-02-28 12:36:22 +01:00
- if (this.isLoaded(blockposition_mutableblockposition.c(k1, 64, l1))) {
2014-11-28 02:17:45 +01:00
- for (int i2 = k - 1; i2 < l; ++i2) {
2015-02-28 12:36:22 +01:00
- blockposition_mutableblockposition.c(k1, i2, l1);
2014-11-28 02:17:45 +01:00
- if (flag && flag1) {
- entity.h(false);
- } else if (!flag && !flag1) {
- entity.h(true);
- }
2015-02-28 12:36:22 +01:00
-
- IBlockData iblockdata1 = iblockdata;
2014-11-28 02:17:45 +01:00
+ // Spigot start
+ int ystart = ( ( k - 1 ) < 0 ) ? 0 : ( k - 1 );
+ for ( int chunkx = ( i >> 4 ); chunkx <= ( ( j - 1 ) >> 4 ); chunkx++ )
+ {
+ int cx = chunkx << 4;
+ for ( int chunkz = ( i1 >> 4 ); chunkz <= ( ( j1 - 1 ) >> 4 ); chunkz++ )
+ {
+ if ( !this.isChunkLoaded( chunkx, chunkz, true ) )
+ {
+ continue;
+ }
+ int cz = chunkz << 4;
+ Chunk chunk = this.getChunkAt( chunkx, chunkz );
+ // Compute ranges within chunk
+ int xstart = ( i < cx ) ? cx : i;
+ int xend = ( j < ( cx + 16 ) ) ? j : ( cx + 16 );
+ int zstart = ( i1 < cz ) ? cz : i1;
+ int zend = ( j1 < ( cz + 16 ) ) ? j1 : ( cz + 16 );
+ // Loop through blocks within chunk
+ for ( int x = xstart; x < xend; x++ )
+ {
+ for ( int z = zstart; z < zend; z++ )
+ {
+ for ( int y = ystart; y < l; y++ )
+ {
+ BlockPosition blockposition = new BlockPosition( x, y, z );
+
+ if (flag && flag1) {
+ entity.h(false);
+ } else if (!flag && !flag1) {
+ entity.h(true);
+ }
2015-02-28 12:36:22 +01:00
- if (worldborder.a((BlockPosition) blockposition_mutableblockposition) || !flag1) {
- iblockdata1 = this.getType(blockposition_mutableblockposition);
2014-11-28 02:17:45 +01:00
+ IBlockData block;
2015-02-28 12:36:22 +01:00
+ if (!this.getWorldBorder().a(blockposition) && flag1) {
2014-11-28 02:17:45 +01:00
+ block = Blocks.STONE.getBlockData();
+ } else
+ {
+ block = chunk.getBlockData( blockposition );
+ }
+ if ( block != null )
+ {
+ block.getBlock().a(this, blockposition, block, axisalignedbb, arraylist, entity);
+ }
}
-
2015-02-28 12:36:22 +01:00
- iblockdata1.getBlock().a(this, blockposition_mutableblockposition, iblockdata1, axisalignedbb, arraylist, entity);
2014-11-28 02:17:45 +01:00
}
}
}
}
+ // Spigot end
double d0 = 0.25D;
List list = this.getEntities(entity, axisalignedbb.grow(d0, d0, d0));
--
2.1.0