testserver/CraftBukkit-Patches/0008-More-Efficient-GetCube...

75 lines
3.0 KiB
Diff
Raw Normal View History

2013-12-01 03:40:53 +00:00
From 4aa2e37f77d90bcae16a89d4aff9727bd4a1fcab Mon Sep 17 00:00:00 2001
2013-06-11 02:18:55 +00: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
2013-12-01 03:40:53 +00:00
index f0a8024..a8dbc44 100644
2013-06-11 02:18:55 +00:00
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
2013-12-01 03:40:53 +00:00
@@ -1015,16 +1015,42 @@ public abstract class World implements IBlockAccess {
2013-06-11 02:18:55 +00:00
int i1 = MathHelper.floor(axisalignedbb.c);
int j1 = MathHelper.floor(axisalignedbb.f + 1.0D);
- for (int k1 = i; k1 < j; ++k1) {
- for (int l1 = i1; l1 < j1; ++l1) {
- if (this.isLoaded(k1, 64, l1)) {
- for (int i2 = k - 1; i2 < l; ++i2) {
2013-12-01 03:40:53 +00:00
- Block block;
2013-06-11 02:18:55 +00:00
-
2013-12-01 03:40:53 +00:00
- if (k1 >= -30000000 && k1 < 30000000 && l1 >= -30000000 && l1 < 30000000) {
- block = this.getType(k1, i2, l1);
- } else {
- block = Blocks.STONE;
2013-06-11 02:18:55 +00: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 ) )
+ {
+ 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++ )
+ {
+ int blkid = chunk.getTypeId( x - cx, y, z - cz );
+ if ( blkid > 0 )
+ {
+ Block block = Block.byId[blkid];
+
+ if ( block != null )
+ {
+ block.a( this, x, y, z, axisalignedbb, this.M, entity );
2013-12-01 03:40:53 +00:00
+ // SPIGOT TODO: THIS DIFF
2013-06-11 02:18:55 +00:00
+ }
+ }
}
2013-12-01 03:40:53 +00:00
block.a(this, k1, i2, l1, axisalignedbb, this.M, entity);
@@ -1032,6 +1058,7 @@ public abstract class World implements IBlockAccess {
2013-06-11 02:18:55 +00:00
}
}
}
+ // Spigot end
double d0 = 0.25D;
List list = this.getEntities(entity, axisalignedbb.grow(d0, d0, d0));
--
2013-12-01 03:40:53 +00:00
1.8.3.2
2013-06-11 02:18:55 +00:00