Paper/CraftBukkit-Patches/0063-More-Efficient-GetCubes.patch
Zach Brown 19972e09b8 Update SpigotMC's patches
5a0150f586ed3eb15fe6f1f596d1a5a7d806f0f9 Fix ITEM_BREAK
e6a3911057bd94d8bd7021cbb4923fb84fb106d1 Upstream merge
d1cdcf8d4c3639f956474f02ed662517cffbe23e Remove old patch
068df64aeee368377e1673667bffc7a6dcf90554 Rebuild all patches
2014-11-30 16:16:48 -06:00

95 lines
4.1 KiB
Diff

From 8565af4935a9f8a438bacca374c5d4460a6ea368 Mon Sep 17 00:00:00 2001
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
index d3ee73d..10f6210 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1050,33 +1050,60 @@ public abstract class World implements IBlockAccess {
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(new BlockPosition(k1, 64, l1))) {
- for (int i2 = k - 1; i2 < l; ++i2) {
- BlockPosition blockposition = new BlockPosition(k1, i2, l1);
- boolean flag = entity.aS();
- boolean flag1 = this.a(this.af(), entity);
-
- if (flag && flag1) {
- entity.h(false);
- } else if (!flag && !flag1) {
- entity.h(true);
- }
+ // 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 );
+ boolean flag = entity.aS();
+ boolean flag1 = this.a(this.af(), entity);
+
+ if (flag && flag1) {
+ entity.h(false);
+ } else if (!flag && !flag1) {
+ entity.h(true);
+ }
- IBlockData iblockdata;
+ IBlockData iblockdata;
- if (!this.af().a(blockposition) && flag1) {
- iblockdata = Blocks.STONE.getBlockData();
- } else {
- iblockdata = this.getType(blockposition);
+ IBlockData block;
+ if (!this.af().a(blockposition) && flag1) {
+ block = Blocks.STONE.getBlockData();
+ } else
+ {
+ block = chunk.getBlockData( blockposition );
+ }
+ if ( block != null )
+ {
+ block.getBlock().a(this, blockposition, block, axisalignedbb, arraylist, entity);
+ }
}
-
- iblockdata.getBlock().a(this, blockposition, iblockdata, axisalignedbb, arraylist, entity);
}
}
}
}
+ // Spigot end
double d0 = 0.25D;
List list = this.getEntities(entity, axisalignedbb.grow(d0, d0, d0));
--
2.1.0