diff options
author | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-06-29 23:02:25 +0100 |
---|---|---|
committer | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-06-30 15:19:25 +0100 |
commit | a679e7f38025924dba3dd688ccb87e92306c4c3e (patch) | |
tree | 604a20c893873bef01a92eaa09d9309f32b7e29c /src/main/java/net/minecraft/server/World.java | |
parent | a98c7ba2c706caa0ba83bddefa5ffecbe658ccd3 (diff) | |
download | craftbukkit-a679e7f38025924dba3dd688ccb87e92306c4c3e.tar craftbukkit-a679e7f38025924dba3dd688ccb87e92306c4c3e.tar.gz craftbukkit-a679e7f38025924dba3dd688ccb87e92306c4c3e.tar.lz craftbukkit-a679e7f38025924dba3dd688ccb87e92306c4c3e.tar.xz craftbukkit-a679e7f38025924dba3dd688ccb87e92306c4c3e.zip |
Update to Minecraft 1.7
Diffstat (limited to 'src/main/java/net/minecraft/server/World.java')
-rw-r--r-- | src/main/java/net/minecraft/server/World.java | 279 |
1 files changed, 174 insertions, 105 deletions
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index 5c9936d3..494c2262 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -1,6 +1,7 @@ package net.minecraft.server; import java.util.ArrayList; +import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -36,12 +37,13 @@ public class World implements IBlockAccess { private TreeSet E = new TreeSet(); private Set F = new HashSet(); public List c = new ArrayList(); + private List G = new ArrayList(); public List players = new ArrayList(); public List e = new ArrayList(); - private long G = 16777215L; + private long H = 16777215L; public int f = 0; protected int g = (new Random()).nextInt(); - protected int h = 1013904223; + protected final int h = 1013904223; protected float i; protected float j; protected float k; @@ -49,7 +51,7 @@ public class World implements IBlockAccess { protected int m = 0; public int n = 0; public boolean suppressPhysics = false; - private long H = System.currentTimeMillis(); + private long I = System.currentTimeMillis(); protected int p = 40; public int spawnMonsters; public Random random = new Random(); @@ -60,16 +62,17 @@ public class World implements IBlockAccess { protected final IDataManager w; public WorldData worldData; // CraftBukkit - protected -> public public boolean isLoading; - private boolean I; + private boolean J; public WorldMapCollection worldMaps; - private ArrayList J = new ArrayList(); - private int K = 0; + private ArrayList K = new ArrayList(); + private boolean L; + private int M = 0; public boolean allowMonsters = true; // CraftBukkit - private -> public public boolean allowAnimals = true; // CraftBukkit - private -> public static int A = 0; - private Set N = new HashSet(); - private int O; - private List P; + private Set P = new HashSet(); + private int Q; + private List R; public boolean isStatic; public WorldChunkManager getWorldChunkManager() { @@ -107,8 +110,8 @@ public class World implements IBlockAccess { this.world = new CraftWorld((WorldServer) this, gen, env); // CraftBukkit end - this.O = this.random.nextInt(12000); - this.P = new ArrayList(); + this.Q = this.random.nextInt(12000); + this.R = new ArrayList(); this.isStatic = false; this.w = idatamanager; this.worldMaps = new WorldMapCollection(idatamanager); @@ -407,7 +410,7 @@ public class World implements IBlockAccess { this.b(i, k, j, i, l, j); } - public void h(int i, int j, int k) { + public void i(int i, int j, int k) { for (int l = 0; l < this.u.size(); ++l) { ((IWorldAccess) this.u.get(l)).a(i, j, k, i, j, k); } @@ -454,7 +457,7 @@ public class World implements IBlockAccess { return this.getChunkAt(i >> 4, k >> 4).c(i & 15, j, k & 15); } - public int j(int i, int j, int k) { + public int k(int i, int j, int k) { if (j < 0) { return 0; } else { @@ -520,7 +523,7 @@ public class World implements IBlockAccess { } } - public boolean l(int i, int j, int k) { + public boolean m(int i, int j, int k) { if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) { if (j < 0) { return false; @@ -558,7 +561,7 @@ public class World implements IBlockAccess { if (!this.worldProvider.e || enumskyblock != EnumSkyBlock.SKY) { if (this.isLoaded(i, j, k)) { if (enumskyblock == EnumSkyBlock.SKY) { - if (this.l(i, j, k)) { + if (this.m(i, j, k)) { l = 15; } } else if (enumskyblock == EnumSkyBlock.BLOCK) { @@ -619,7 +622,7 @@ public class World implements IBlockAccess { } } - public float m(int i, int j, int k) { + public float n(int i, int j, int k) { return this.worldProvider.f[this.getLightLevel(i, j, k)]; } @@ -648,7 +651,7 @@ public class World implements IBlockAccess { int l1 = this.getData(l, i1, j1); Block block = Block.byId[k1]; - if ((!flag1 || block == null || block.d(this, l, i1, j1) != null) && k1 > 0 && block.a(l1, flag)) { + if ((!flag1 || block == null || block.e(this, l, i1, j1) != null) && k1 > 0 && block.a(l1, flag)) { MovingObjectPosition movingobjectposition = block.a(this, l, i1, j1, vec3d, vec3d1); if (movingobjectposition != null) { @@ -776,7 +779,7 @@ public class World implements IBlockAccess { int j2 = this.getData(l, i1, j1); Block block1 = Block.byId[i2]; - if ((!flag1 || block1 == null || block1.d(this, l, i1, j1) != null) && i2 > 0 && block1.a(j2, flag)) { + if ((!flag1 || block1 == null || block1.e(this, l, i1, j1) != null) && i2 > 0 && block1.a(j2, flag)) { MovingObjectPosition movingobjectposition1 = block1.a(this, l, i1, j1, vec3d, vec3d1); if (movingobjectposition1 != null) { @@ -906,10 +909,10 @@ public class World implements IBlockAccess { this.everyoneSleeping(); } - int i = entity.bG; - int j = entity.bI; + int i = entity.bH; + int j = entity.bJ; - if (entity.bF && this.isChunkLoaded(i, j)) { + if (entity.bG && this.isChunkLoaded(i, j)) { this.getChunkAt(i, j).b(entity); } @@ -922,7 +925,7 @@ public class World implements IBlockAccess { } public List getEntities(Entity entity, AxisAlignedBB axisalignedbb) { - this.J.clear(); + this.K.clear(); int i = MathHelper.floor(axisalignedbb.a); int j = MathHelper.floor(axisalignedbb.d + 1.0D); int k = MathHelper.floor(axisalignedbb.b); @@ -937,7 +940,7 @@ public class World implements IBlockAccess { Block block = Block.byId[this.getTypeId(k1, i2, l1)]; if (block != null) { - block.a(this, k1, i2, l1, axisalignedbb, this.J); + block.a(this, k1, i2, l1, axisalignedbb, this.K); } } } @@ -951,16 +954,16 @@ public class World implements IBlockAccess { AxisAlignedBB axisalignedbb1 = ((Entity) list.get(j2)).e_(); if (axisalignedbb1 != null && axisalignedbb1.a(axisalignedbb)) { - this.J.add(axisalignedbb1); + this.K.add(axisalignedbb1); } axisalignedbb1 = entity.a_((Entity) list.get(j2)); if (axisalignedbb1 != null && axisalignedbb1.a(axisalignedbb)) { - this.J.add(axisalignedbb1); + this.K.add(axisalignedbb1); } } - return this.J; + return this.K; } public int a(float f) { @@ -1058,7 +1061,7 @@ public class World implements IBlockAccess { continue; } // CraftBukkit end - entity.o_(); + entity.m_(); if (entity.dead) { this.e.remove(i--); } @@ -1071,9 +1074,9 @@ public class World implements IBlockAccess { for (i = 0; i < this.D.size(); ++i) { entity = (Entity) this.D.get(i); - j = entity.bG; - k = entity.bI; - if (entity.bF && this.isChunkLoaded(j, k)) { + j = entity.bH; + k = entity.bJ; + if (entity.bG && this.isChunkLoaded(j, k)) { this.getChunkAt(j, k).b(entity); } } @@ -1100,9 +1103,9 @@ public class World implements IBlockAccess { } if (entity.dead) { - j = entity.bG; - k = entity.bI; - if (entity.bF && this.isChunkLoaded(j, k)) { + j = entity.bH; + k = entity.bJ; + if (entity.bG && this.isChunkLoaded(j, k)) { this.getChunkAt(j, k).b(entity); } @@ -1111,10 +1114,57 @@ public class World implements IBlockAccess { } } - for (i = 0; i < this.c.size(); ++i) { - TileEntity tileentity = (TileEntity) this.c.get(i); + this.L = true; + Iterator iterator = this.c.iterator(); - tileentity.g_(); + while (iterator.hasNext()) { + TileEntity tileentity = (TileEntity) iterator.next(); + + if (!tileentity.g()) { + tileentity.g_(); + } + + if (tileentity.g()) { + iterator.remove(); + Chunk chunk = this.getChunkAt(tileentity.x >> 4, tileentity.z >> 4); + + if (chunk != null) { + chunk.e(tileentity.x & 15, tileentity.y, tileentity.z & 15); + } + } + } + + this.L = false; + if (!this.G.isEmpty()) { + Iterator iterator1 = this.G.iterator(); + + while (iterator1.hasNext()) { + TileEntity tileentity1 = (TileEntity) iterator1.next(); + + if (!tileentity1.g()) { + if (!this.c.contains(tileentity1)) { + this.c.add(tileentity1); + } + + Chunk chunk1 = this.getChunkAt(tileentity1.x >> 4, tileentity1.z >> 4); + + if (chunk1 != null) { + chunk1.a(tileentity1.x & 15, tileentity1.y, tileentity1.z & 15, tileentity1); + } + + this.notify(tileentity1.x, tileentity1.y, tileentity1.z); + } + } + + this.G.clear(); + } + } + + public void a(Collection collection) { + if (this.L) { + this.G.addAll(collection); + } else { + this.c.addAll(collection); } } @@ -1133,11 +1183,11 @@ public class World implements IBlockAccess { entity.bq = entity.locZ; entity.lastYaw = entity.yaw; entity.lastPitch = entity.pitch; - if (flag && entity.bF) { + if (flag && entity.bG) { if (entity.vehicle != null) { - entity.D(); + entity.E(); } else { - entity.o_(); + entity.m_(); } } @@ -1165,20 +1215,20 @@ public class World implements IBlockAccess { int l = MathHelper.floor(entity.locY / 16.0D); int i1 = MathHelper.floor(entity.locZ / 16.0D); - if (!entity.bF || entity.bG != k || entity.bH != l || entity.bI != i1) { - if (entity.bF && this.isChunkLoaded(entity.bG, entity.bI)) { - this.getChunkAt(entity.bG, entity.bI).a(entity, entity.bH); + if (!entity.bG || entity.bH != k || entity.bI != l || entity.bJ != i1) { + if (entity.bG && this.isChunkLoaded(entity.bH, entity.bJ)) { + this.getChunkAt(entity.bH, entity.bJ).a(entity, entity.bI); } if (this.isChunkLoaded(k, i1)) { - entity.bF = true; + entity.bG = true; this.getChunkAt(k, i1).a(entity); } else { - entity.bF = false; + entity.bG = false; } } - if (flag && entity.bF && entity.passenger != null) { + if (flag && entity.bG && entity.passenger != null) { if (!entity.passenger.dead && entity.passenger.vehicle == entity) { this.playerJoinedWorld(entity.passenger); } else { @@ -1474,18 +1524,38 @@ public class World implements IBlockAccess { } public void setTileEntity(int i, int j, int k, TileEntity tileentity) { - Chunk chunk = this.getChunkAt(i >> 4, k >> 4); + if (!tileentity.g()) { + if (this.L) { + tileentity.x = i; + tileentity.y = j; + tileentity.z = k; + this.G.add(tileentity); + } else { + this.c.add(tileentity); + Chunk chunk = this.getChunkAt(i >> 4, k >> 4); - if (chunk != null) { - chunk.a(i & 15, j, k & 15, tileentity); + if (chunk != null) { + chunk.a(i & 15, j, k & 15, tileentity); + } + } } } public void o(int i, int j, int k) { - Chunk chunk = this.getChunkAt(i >> 4, k >> 4); + TileEntity tileentity = this.getTileEntity(i, j, k); + + if (tileentity != null && this.L) { + tileentity.h(); + } else { + if (tileentity != null) { + this.c.remove(tileentity); + } - if (chunk != null) { - chunk.e(i & 15, j, k & 15); + Chunk chunk = this.getChunkAt(i >> 4, k >> 4); + + if (chunk != null) { + chunk.e(i & 15, j, k & 15); + } } } @@ -1495,23 +1565,23 @@ public class World implements IBlockAccess { return block == null ? false : block.a(); } - public boolean d(int i, int j, int k) { + public boolean e(int i, int j, int k) { Block block = Block.byId[this.getTypeId(i, j, k)]; return block == null ? false : block.material.h() && block.b(); } public boolean doLighting() { - if (this.K >= 50) { + if (this.M >= 50) { return false; } else { - ++this.K; - - boolean flag; + ++this.M; try { int i = 500; + boolean flag; + while (this.C.size() > 0) { --i; if (i <= 0) { @@ -1523,11 +1593,10 @@ public class World implements IBlockAccess { } flag = false; + return flag; } finally { - --this.K; + --this.M; } - - return flag; } } @@ -1547,37 +1616,37 @@ public class World implements IBlockAccess { int k1 = (l + i) / 2; int l1 = (j1 + k) / 2; - if (!this.isLoaded(k1, 64, l1)) { - return; - } - - if (this.getChunkAtWorldCoords(k1, l1).isEmpty()) { - return; - } + if (this.isLoaded(k1, 64, l1)) { + if (this.getChunkAtWorldCoords(k1, l1).isEmpty()) { + return; + } - int i2 = this.C.size(); - int j2; + int i2 = this.C.size(); + int j2; - if (flag) { - j2 = 5; - if (j2 > i2) { - j2 = i2; - } + if (flag) { + j2 = 5; + if (j2 > i2) { + j2 = i2; + } - for (int k2 = 0; k2 < j2; ++k2) { - MetadataChunkBlock metadatachunkblock = (MetadataChunkBlock) this.C.get(this.C.size() - k2 - 1); + for (int k2 = 0; k2 < j2; ++k2) { + MetadataChunkBlock metadatachunkblock = (MetadataChunkBlock) this.C.get(this.C.size() - k2 - 1); - if (metadatachunkblock.a == enumskyblock && metadatachunkblock.a(i, j, k, l, i1, j1)) { - return; + if (metadatachunkblock.a == enumskyblock && metadatachunkblock.a(i, j, k, l, i1, j1)) { + return; + } } } - } - this.C.add(new MetadataChunkBlock(enumskyblock, i, j, k, l, i1, j1)); - j2 = 1000000; - if (this.C.size() > 1000000) { - System.out.println("More than " + j2 + " updates, aborting lighting updates"); - this.C.clear(); + this.C.add(new MetadataChunkBlock(enumskyblock, i, j, k, l, i1, j1)); + j2 = 1000000; + if (this.C.size() > 1000000) { + System.out.println("More than " + j2 + " updates, aborting lighting updates"); + this.C.clear(); + } + + return; } } finally { --A; @@ -1754,7 +1823,7 @@ public class World implements IBlockAccess { } protected void j() { - this.N.clear(); + this.P.clear(); int i; int j; @@ -1770,16 +1839,16 @@ public class World implements IBlockAccess { for (k = -b0; k <= b0; ++k) { for (l = -b0; l <= b0; ++l) { - this.N.add(new ChunkCoordIntPair(k + i, l + j)); + this.P.add(new ChunkCoordIntPair(k + i, l + j)); } } } - if (this.O > 0) { - --this.O; + if (this.Q > 0) { + --this.Q; } - Iterator iterator = this.N.iterator(); + Iterator iterator = this.P.iterator(); while (iterator.hasNext()) { ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) iterator.next(); @@ -1791,8 +1860,8 @@ public class World implements IBlockAccess { int k1; int l1; - if (this.O == 0) { - this.g = this.g * 3 + this.h; + if (this.Q == 0) { + this.g = this.g * 3 + 1013904223; k = this.g >> 2; l = k & 15; j1 = k >> 8 & 15; @@ -1800,18 +1869,18 @@ public class World implements IBlockAccess { l1 = chunk.getTypeId(l, k1, j1); l += i; j1 += j; - if (l1 == 0 && this.j(l, k1, j1) <= this.random.nextInt(8) && this.a(EnumSkyBlock.SKY, l, k1, j1) <= 0) { + if (l1 == 0 && this.k(l, k1, j1) <= this.random.nextInt(8) && this.a(EnumSkyBlock.SKY, l, k1, j1) <= 0) { EntityHuman entityhuman1 = this.a((double) l + 0.5D, (double) k1 + 0.5D, (double) j1 + 0.5D, 8.0D); if (entityhuman1 != null && entityhuman1.d((double) l + 0.5D, (double) k1 + 0.5D, (double) j1 + 0.5D) > 4.0D) { this.makeSound((double) l + 0.5D, (double) k1 + 0.5D, (double) j1 + 0.5D, "ambient.cave.cave", 0.7F, 0.8F + this.random.nextFloat() * 0.2F); - this.O = this.random.nextInt(12000) + 6000; + this.Q = this.random.nextInt(12000) + 6000; } } } if (this.random.nextInt(100000) == 0 && this.v() && this.u()) { - this.g = this.g * 3 + this.h; + this.g = this.g * 3 + 1013904223; k = this.g >> 2; l = i + (k & 15); j1 = j + (k >> 8 & 15); @@ -1825,7 +1894,7 @@ public class World implements IBlockAccess { int i2; if (this.random.nextInt(16) == 0) { - this.g = this.g * 3 + this.h; + this.g = this.g * 3 + 1013904223; k = this.g >> 2; l = k & 15; j1 = k >> 8 & 15; @@ -1861,7 +1930,7 @@ public class World implements IBlockAccess { } for (k = 0; k < 80; ++k) { - this.g = this.g * 3 + this.h; + this.g = this.g * 3 + 1013904223; l = this.g >> 2; j1 = l & 15; k1 = l >> 8 & 15; @@ -1909,7 +1978,7 @@ public class World implements IBlockAccess { } public List b(Entity entity, AxisAlignedBB axisalignedbb) { - this.P.clear(); + this.R.clear(); int i = MathHelper.floor((axisalignedbb.a - 2.0D) / 16.0D); int j = MathHelper.floor((axisalignedbb.d + 2.0D) / 16.0D); int k = MathHelper.floor((axisalignedbb.c - 2.0D) / 16.0D); @@ -1918,12 +1987,12 @@ public class World implements IBlockAccess { for (int i1 = i; i1 <= j; ++i1) { for (int j1 = k; j1 <= l; ++j1) { if (this.isChunkLoaded(i1, j1)) { - this.getChunkAt(i1, j1).a(entity, axisalignedbb, this.P); + this.getChunkAt(i1, j1).a(entity, axisalignedbb, this.R); } } } - return this.P; + return this.R; } public List a(Class oclass, AxisAlignedBB axisalignedbb) { @@ -1992,7 +2061,7 @@ public class World implements IBlockAccess { int j1 = this.getTypeId(j, k, l); Block block = Block.byId[j1]; Block block1 = Block.byId[i]; - AxisAlignedBB axisalignedbb = block1.d(this, j, k, l); + AxisAlignedBB axisalignedbb = block1.e(this, j, k, l); if (flag) { axisalignedbb = null; @@ -2053,7 +2122,7 @@ public class World implements IBlockAccess { public boolean isBlockFacePowered(int i, int j, int k, int l) { int i1 = this.getTypeId(i, j, k); - return i1 == 0 ? false : Block.byId[i1].c(this, i, j, k, l); + return i1 == 0 ? false : Block.byId[i1].d(this, i, j, k, l); } public boolean isBlockPowered(int i, int j, int k) { @@ -2061,7 +2130,7 @@ public class World implements IBlockAccess { } public boolean isBlockFaceIndirectlyPowered(int i, int j, int k, int l) { - if (this.d(i, j, k)) { + if (this.e(i, j, k)) { return this.isBlockPowered(i, j, k); } else { int i1 = this.getTypeId(i, j, k); @@ -2206,7 +2275,7 @@ public class World implements IBlockAccess { } public void everyoneSleeping() { - this.I = !this.players.isEmpty(); + this.J = !this.players.isEmpty(); Iterator iterator = this.players.iterator(); while (iterator.hasNext()) { @@ -2214,7 +2283,7 @@ public class World implements IBlockAccess { // CraftBukkit if (!entityhuman.isSleeping() && !entityhuman.fauxSleeping) { - this.I = false; + this.J = false; break; } } @@ -2231,7 +2300,7 @@ public class World implements IBlockAccess { // CraftBukkit end protected void s() { - this.I = false; + this.J = false; Iterator iterator = this.players.iterator(); while (iterator.hasNext()) { @@ -2246,7 +2315,7 @@ public class World implements IBlockAccess { } public boolean everyoneDeeplySleeping() { - if (this.I && !this.isStatic) { + if (this.J && !this.isStatic) { Iterator iterator = this.players.iterator(); // CraftBukkit - This allows us to assume that some people are in bed but not really, allowing time to pass in spite of AFKers |