From 6aae6f32e45bdec796a89dfd871fa0cf58babc3f Mon Sep 17 00:00:00 2001 From: Sen Date: Mon, 19 May 2025 16:34:44 +0200 Subject: [PATCH] remove chunk height --- .../src/client/renderer/EntityRenderer.java | 6 +- client/src/client/world/EmptyChunk.java | 11 -- common/src/common/ai/EntityAIFleeSun.java | 95 --------------- common/src/common/ai/EntityAIRestrictSun.java | 39 ------ common/src/common/block/BlockCrops.java | 2 +- .../common/entity/projectile/EntityHook.java | 5 - .../src/common/pathfinding/PathNavigate.java | 9 -- .../pathfinding/PathNavigateGround.java | 33 ------ common/src/common/world/Chunk.java | 112 ------------------ common/src/common/world/World.java | 66 ++++------- server/src/server/biome/BiomeChaos.java | 2 +- server/src/server/biome/BiomeDesert.java | 2 +- server/src/server/biome/BiomeForest.java | 4 +- server/src/server/biome/BiomeJungle.java | 2 +- server/src/server/biome/BiomePlains.java | 4 +- server/src/server/biome/BiomeSavanna.java | 2 +- server/src/server/biome/BiomeSnow.java | 4 +- server/src/server/biome/BiomeTaiga.java | 4 +- server/src/server/biome/BiomeTian.java | 2 +- server/src/server/biome/GenBiome.java | 28 ++--- .../src/server/village/VillageCollection.java | 17 +-- server/src/server/world/Region.java | 2 - server/src/server/world/Spawner.java | 6 +- server/src/server/world/WorldServer.java | 16 +-- 24 files changed, 75 insertions(+), 398 deletions(-) delete mode 100755 common/src/common/ai/EntityAIFleeSun.java delete mode 100755 common/src/common/ai/EntityAIRestrictSun.java diff --git a/client/src/client/renderer/EntityRenderer.java b/client/src/client/renderer/EntityRenderer.java index 9e5bf48..9feb379 100755 --- a/client/src/client/renderer/EntityRenderer.java +++ b/client/src/client/renderer/EntityRenderer.java @@ -1143,7 +1143,7 @@ public class EntityRenderer { for (int l = 0; l < k; ++l) { - BlockPos blockpos1 = world.getPrecipitationHeight(blockpos.add(this.random.zrange(i) - this.random.zrange(i), 0, this.random.zrange(i) - this.random.zrange(i))); + BlockPos blockpos1 = world.getPrecipitationHeight(blockpos.add(this.random.zrange(i) - this.random.zrange(i), 0, this.random.zrange(i) - this.random.zrange(i)), blockpos.getY() + 64, 96); Biome biomegenbase = world.getBiomeGenForCoords(blockpos1); BlockPos blockpos2 = blockpos1.down(); Block block = world.getState(blockpos2).getBlock(); @@ -1189,7 +1189,7 @@ public class EntityRenderer { { this.rainSoundCounter = 0; - if (d1 > (double)(blockpos.getY() + 1) && world.getPrecipitationHeight(blockpos).getY() > ExtMath.floorf((float)blockpos.getY())) + if (d1 > (double)(blockpos.getY() + 1) && world.getPrecipitationHeight(blockpos, blockpos.getY() + 64, 96).getY() > ExtMath.floorf((float)blockpos.getY())) { this.gm.world.playSound(d0, d1, d2, n >= j ? this.pickMoltenSound() : SoundEvent.RAIN, n >= j ? 0.2f : 0.1F); } @@ -1257,7 +1257,7 @@ public class EntityRenderer { // if (biomegenbase.canRain() || biomegenbase.isSnowyBiome()) // { - int j2 = world.getPrecipitationHeight(blockpos$mutableblockpos).getY(); + int j2 = world.getPrecipitationHeight(blockpos$mutableblockpos, ExtMath.floord(d1) + 64, 96).getY(); int k2 = j - i1; int l2 = j + i1; diff --git a/client/src/client/world/EmptyChunk.java b/client/src/client/world/EmptyChunk.java index 63c8b56..6bec1b5 100755 --- a/client/src/client/world/EmptyChunk.java +++ b/client/src/client/world/EmptyChunk.java @@ -16,13 +16,6 @@ public class EmptyChunk extends Chunk { super(world, 0, 0); } - public int getHeight(int x, int z) { - return 0; - } - - public void genHeights() { - } - public Block getBlock(BlockPos pos) { return Blocks.air; } @@ -52,10 +45,6 @@ public class EmptyChunk extends Chunk { public void removeEntity(Entity entity) { } - public boolean canSeeSky(BlockPos pos) { - return false; - } - public TileEntity getTileEntity(BlockPos pos, TileEntity.EnumCreateEntityType type) { return null; } diff --git a/common/src/common/ai/EntityAIFleeSun.java b/common/src/common/ai/EntityAIFleeSun.java deleted file mode 100755 index 85c8c7e..0000000 --- a/common/src/common/ai/EntityAIFleeSun.java +++ /dev/null @@ -1,95 +0,0 @@ -package common.ai; - -import common.entity.types.EntityLiving; -import common.rng.Random; -import common.util.BlockPos; -import common.util.Vec3; -import common.world.World; -import common.world.AWorldServer; - -public class EntityAIFleeSun extends EntityAIBase -{ - private EntityLiving theCreature; - private double shelterX; - private double shelterY; - private double shelterZ; - private double movementSpeed; - private World theWorld; - - public EntityAIFleeSun(EntityLiving theCreatureIn, double movementSpeedIn) - { - this.theCreature = theCreatureIn; - this.movementSpeed = movementSpeedIn; - this.theWorld = theCreatureIn.worldObj; - this.setMutexBits(1); - } - - /** - * Returns whether the EntityAIBase should begin execution. - */ - public boolean shouldExecute() - { - if (!((AWorldServer)this.theWorld).isDaytime()) - { - return false; - } - else if (!this.theCreature.isBurning()) - { - return false; - } - else if (!this.theWorld.canSeeSky(new BlockPos(this.theCreature.posX, this.theCreature.getEntityBoundingBox().minY, this.theCreature.posZ))) - { - return false; - } - else - { - Vec3 vec3 = this.findPossibleShelter(); - - if (vec3 == null) - { - return false; - } - else - { - this.shelterX = vec3.xCoord; - this.shelterY = vec3.yCoord; - this.shelterZ = vec3.zCoord; - return true; - } - } - } - - /** - * Returns whether an in-progress EntityAIBase should continue executing - */ - public boolean continueExecuting() - { - return !this.theCreature.getNavigator().noPath(); - } - - /** - * Execute a one shot task or start executing a continuous task - */ - public void startExecuting() - { - this.theCreature.getNavigator().tryMoveToXYZ(this.shelterX, this.shelterY, this.shelterZ, this.movementSpeed); - } - - private Vec3 findPossibleShelter() - { - Random random = this.theCreature.getRNG(); - BlockPos blockpos = new BlockPos(this.theCreature.posX, this.theCreature.getEntityBoundingBox().minY, this.theCreature.posZ); - - for (int i = 0; i < 10; ++i) - { - BlockPos blockpos1 = blockpos.add(random.zrange(20) - 10, random.zrange(6) - 3, random.zrange(20) - 10); - - if (!this.theWorld.canSeeSky(blockpos1) && this.theCreature.getBlockPathWeight(blockpos1) < 0.0F) - { - return new Vec3((double)blockpos1.getX(), (double)blockpos1.getY(), (double)blockpos1.getZ()); - } - } - - return null; - } -} diff --git a/common/src/common/ai/EntityAIRestrictSun.java b/common/src/common/ai/EntityAIRestrictSun.java deleted file mode 100755 index 50e2901..0000000 --- a/common/src/common/ai/EntityAIRestrictSun.java +++ /dev/null @@ -1,39 +0,0 @@ -package common.ai; - -import common.entity.types.EntityLiving; -import common.pathfinding.PathNavigateGround; -import common.world.AWorldServer; - -public class EntityAIRestrictSun extends EntityAIBase -{ - private EntityLiving theEntity; - - public EntityAIRestrictSun(EntityLiving creature) - { - this.theEntity = creature; - } - - /** - * Returns whether the EntityAIBase should begin execution. - */ - public boolean shouldExecute() - { - return ((AWorldServer)this.theEntity.worldObj).isDaytime(); - } - - /** - * Execute a one shot task or start executing a continuous task - */ - public void startExecuting() - { - ((PathNavigateGround)this.theEntity.getNavigator()).setAvoidSun(true); - } - - /** - * Resets the task - */ - public void resetTask() - { - ((PathNavigateGround)this.theEntity.getNavigator()).setAvoidSun(false); - } -} diff --git a/common/src/common/block/BlockCrops.java b/common/src/common/block/BlockCrops.java index fee8af4..fbf07d6 100755 --- a/common/src/common/block/BlockCrops.java +++ b/common/src/common/block/BlockCrops.java @@ -129,7 +129,7 @@ public class BlockCrops extends BlockBush implements IGrowable public boolean canBlockStay(World worldIn, BlockPos pos, State state) { - return (worldIn.getLight(pos) >= 8 || worldIn.canSeeSky(pos)) && this.canPlaceBlockOn(worldIn.getState(pos.down()).getBlock()); + return this.canPlaceBlockOn(worldIn.getState(pos.down()).getBlock()); } protected Item getSeed() diff --git a/common/src/common/entity/projectile/EntityHook.java b/common/src/common/entity/projectile/EntityHook.java index 8e51dd4..c2c13c9 100755 --- a/common/src/common/entity/projectile/EntityHook.java +++ b/common/src/common/entity/projectile/EntityHook.java @@ -393,11 +393,6 @@ public class EntityHook extends Entity implements IObjectData l = 2; } - if (this.rand.floatv() < 0.5F && !this.worldObj.canSeeSky(blockpos)) - { - --l; - } - if (this.ticksCatchable > 0) { --this.ticksCatchable; diff --git a/common/src/common/pathfinding/PathNavigate.java b/common/src/common/pathfinding/PathNavigate.java index 0d8fb09..8044438 100755 --- a/common/src/common/pathfinding/PathNavigate.java +++ b/common/src/common/pathfinding/PathNavigate.java @@ -163,8 +163,6 @@ public abstract class PathNavigate this.currentPath = pathentityIn; } - this.removeSunnyPath(); - if (this.currentPath.getCurrentPathLength() == 0) { return false; @@ -322,13 +320,6 @@ public abstract class PathNavigate return this.theEntity.isInLiquid() || this.theEntity.isInMolten(); } - /** - * Trims path data from the end to the first sun covered block - */ - protected void removeSunnyPath() - { - } - /** * Returns true when an entity of specified size could safely walk in a straight line between the two points. Args: * pos1, pos2, entityXSize, entityYSize, entityZSize diff --git a/common/src/common/pathfinding/PathNavigateGround.java b/common/src/common/pathfinding/PathNavigateGround.java index f12b1c8..afef617 100755 --- a/common/src/common/pathfinding/PathNavigateGround.java +++ b/common/src/common/pathfinding/PathNavigateGround.java @@ -13,7 +13,6 @@ import common.world.World; public class PathNavigateGround extends PathNavigate { protected WalkNodeProcessor nodeProcessor; - private boolean shouldAvoidSun; public PathNavigateGround(EntityLiving entitylivingIn, World worldIn) { @@ -71,33 +70,6 @@ public class PathNavigateGround extends PathNavigate } } - /** - * Trims path data from the end to the first sun covered block - */ - protected void removeSunnyPath() - { - super.removeSunnyPath(); - - if (this.shouldAvoidSun) - { - if (this.worldObj.canSeeSky(new BlockPos(ExtMath.floord(this.theEntity.posX), (int)(this.theEntity.getEntityBoundingBox().minY + 0.5D), ExtMath.floord(this.theEntity.posZ)))) - { - return; - } - - for (int i = 0; i < this.currentPath.getCurrentPathLength(); ++i) - { - PathPoint pathpoint = this.currentPath.getPathPointFromIndex(i); - - if (this.worldObj.canSeeSky(new BlockPos(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord))) - { - this.currentPath.setCurrentPathLength(i - 1); - return; - } - } - } - } - /** * Returns true when an entity of specified size could safely walk in a straight line between the two points. Args: * pos1, pos2, entityXSize, entityYSize, entityZSize @@ -286,9 +258,4 @@ public class PathNavigateGround extends PathNavigate { return this.nodeProcessor.getCanSwim(); } - - public void setAvoidSun(boolean par1) - { - this.shouldAvoidSun = par1; - } } diff --git a/common/src/common/world/Chunk.java b/common/src/common/world/Chunk.java index 8bd4b7e..fb6f0a8 100755 --- a/common/src/common/world/Chunk.java +++ b/common/src/common/world/Chunk.java @@ -33,8 +33,6 @@ public class Chunk { private final World world; private final BlockArray[] blocks = new BlockArray[32]; private final byte[] biomes = new byte[256]; - private final int[] precHeight = new int[256]; - private final int[] height = new int[256]; private final Map tiles = Maps.newHashMap(); private final ClassInheritanceMultiMap[] entities = new ClassInheritanceMultiMap[32]; private final ConcurrentLinkedQueue tileQueue = new ConcurrentLinkedQueue(); @@ -44,7 +42,6 @@ public class Chunk { private boolean updated; private boolean modified; private boolean hasEntity; - private int minHeight; private int lightChecks = 8192; private long lastSave; private long inhabited; @@ -56,7 +53,6 @@ public class Chunk { for(int y = 0; y < this.entities.length; ++y) { this.entities[y] = new ClassInheritanceMultiMap(Entity.class); } - Arrays.fill(this.precHeight, -999); Arrays.fill(this.biomes, (byte)-1); } @@ -110,54 +106,9 @@ public class Chunk { this.resetRelight(); } - public int getHeight(BlockPos pos) { - return this.getHeight(pos.getX() & 15, pos.getZ() & 15); - } - - public int getHeight(int x, int z) { - return this.height[z << 4 | x]; - } - - public int getTopSegment() { - for(int y = this.blocks.length - 1; y >= 0; --y) { - if(this.blocks[y] != null) { - return this.blocks[y].getY(); - } - } - - return 0; - } - public BlockArray[] getStorage() { return this.blocks; } - - protected void genHeights() { - int h = this.getTopSegment(); - this.minHeight = Integer.MAX_VALUE; - - for(int x = 0; x < 16; ++x) { - for(int z = 0; z < 16; ++z) { - this.precHeight[x + (z << 4)] = -999; - - for(int y = h + 16; y > 0; --y) { - Block block = this.getBlock0(x, y - 1, z); - - if(block.getLightOpacity() != 0) { - this.height[z << 4 | x] = y; - - if(y < this.minHeight) { - this.minHeight = y; - } - - break; - } - } - } - } - - this.modified = true; - } public int getOpacity(BlockPos pos) { return this.getBlock(pos).getLightOpacity(); @@ -239,11 +190,6 @@ public class Chunk { int z = pos.getZ() & 15; int o = z << 4 | x; - if(y >= this.precHeight[o] - 1) { - this.precHeight[o] = -999; - } - - int h = this.height[o]; State old = this.getState(pos); if(old == state) { @@ -395,13 +341,6 @@ public class Chunk { this.entities[y].remove(entity); } - public boolean canSeeSky(BlockPos pos) { - int x = pos.getX() & 15; - int y = pos.getY(); - int z = pos.getZ() & 15; - return y >= this.height[z << 4 | x]; - } - private TileEntity createNewTileEntity(BlockPos pos) { Block block = this.getBlock(pos); return !block.hasTileEntity() ? null : ((ITileEntityProvider)block).createNewTileEntity(this.world, this.getMeta(pos)); @@ -556,37 +495,6 @@ public class Chunk { return false; } - public BlockPos getPrecipitation(BlockPos pos) { - int x = pos.getX() & 15; - int z = pos.getZ() & 15; - int o = x | z << 4; - BlockPos loc = new BlockPos(pos.getX(), this.precHeight[o], pos.getZ()); - - if(loc.getY() == -999) { - int y = this.getTopSegment() + 15; - loc = new BlockPos(pos.getX(), y, pos.getZ()); - int h = -1; - - while(loc.getY() > 0 && h == -1) { - Block block = this.getBlock(loc); - Material mat = block.getMaterial(); - - if((!mat.blocksMovement() && !mat.isLiquid()) - || (mat == Material.leaves && ((mat = this.getBlock(loc.up()).getMaterial()) == Material.snow) - || mat == Material.leaves)) { - loc = loc.down(); - } - else { - h = loc.getY() + 1; - } - } - - this.precHeight[o] = h; - } - - return new BlockPos(pos.getX(), this.precHeight[o], pos.getZ()); - } - public void update() { this.updated = true; @@ -682,7 +590,6 @@ public class Chunk { } this.populated = true; - this.genHeights(); for(TileEntity tile : this.tiles.values()) { tile.updateContainingBlockInfo(); @@ -773,21 +680,6 @@ public class Chunk { return this.world; } - public int[] getHeights() { - return this.height; - } - - public void setHeights(int[] map) { - if(this.height.length != map.length) { - Log.JNI.warn("Konnte Höhen des Chunks nicht setzen, Länge des Arrays ist " + map.length + " statt " + this.height.length); - } - else { - for(int n = 0; n < this.height.length; ++n) { - this.height[n] = map[n]; - } - } - } - public Map getTiles() { return this.tiles; } @@ -816,10 +708,6 @@ public class Chunk { this.lastSave = time; } - public int getLowest() { - return this.minHeight; - } - public long getInhabited() { return this.inhabited; } diff --git a/common/src/common/world/World.java b/common/src/common/world/World.java index 619868a..5e3c608 100755 --- a/common/src/common/world/World.java +++ b/common/src/common/world/World.java @@ -333,10 +333,6 @@ public abstract class World implements IWorldAccess { } } - public boolean canSeeSky(BlockPos pos) { - return this.getChunk(pos).canSeeSky(pos); - } - public int getLight(BlockPos pos) { if(pos.getY() < 0) { return 0; @@ -398,39 +394,6 @@ public abstract class World implements IWorldAccess { } } - public BlockPos getHeight(BlockPos pos) { - int i; - - if(pos.getX() >= -MAX_SIZE && pos.getZ() >= -MAX_SIZE && pos.getX() < MAX_SIZE && pos.getZ() < MAX_SIZE) { - if(this.isLoaded(pos.getX() >> 4, pos.getZ() >> 4, true)) { - i = this.getChunk(pos.getX() >> 4, pos.getZ() >> 4).getHeight(pos.getX() & 15, pos.getZ() & 15); - } - else { - i = 0; - } - } - else { - i = this.getSeaLevel() + 1; - } - - return new BlockPos(pos.getX(), i, pos.getZ()); - } - - public int getChunksLowestHorizon(int x, int z) { - if(x >= -MAX_SIZE && z >= -MAX_SIZE && x < MAX_SIZE && z < MAX_SIZE) { - if(!this.isLoaded(x >> 4, z >> 4, true)) { - return 0; - } - else { - Chunk chunk = this.getChunk(x >> 4, z >> 4); - return chunk.getLowest(); - } - } - else { - return this.getSeaLevel() + 1; - } - } - public int getLightFromNeighborsFor(BlockPos pos) { if(pos.getY() < 0) { pos = new BlockPos(pos.getX(), 0, pos.getZ()); @@ -923,8 +886,30 @@ public abstract class World implements IWorldAccess { return f * (float)Math.PI * 2.0F; } + public BlockPos getPrecipitationHeight(BlockPos pos, int y, int scan) { + scan = y - scan; + BlockPos loc = new BlockPos(pos.getX(), y, pos.getZ()); + y = -1; + + while(loc.getY() > 0 && loc.getY() >= scan && y == -1) { + Block block = this.getState(loc).getBlock(); + Material mat = block.getMaterial(); + + if((!mat.blocksMovement() && !mat.isLiquid()) + || (mat == Material.leaves && ((mat = this.getState(loc.up()).getBlock().getMaterial()) == Material.snow) + || mat == Material.leaves)) { + loc = loc.down(); + } + else { + y = loc.getY() + 1; + } + } + + return new BlockPos(pos.getX(), y, pos.getZ()); + } + public BlockPos getPrecipitationHeight(BlockPos pos) { - return this.getChunk(pos).getPrecipitation(pos); + return this.getPrecipitationHeight(pos, 256, 256); } public void updateEntities() { @@ -2040,10 +2025,7 @@ public abstract class World implements IWorldAccess { if(wet ? !this.isRaining() : !this.hasDownfall()) { return false; } - else if(!this.canSeeSky(strikePosition)) { - return false; - } - else if(this.getPrecipitationHeight(strikePosition).getY() > strikePosition.getY()) { + else if(this.getPrecipitationHeight(strikePosition, strikePosition.getY() + 64, 96).getY() > strikePosition.getY()) { return false; } return !this.canSnowAt(strikePosition, false, false); diff --git a/server/src/server/biome/BiomeChaos.java b/server/src/server/biome/BiomeChaos.java index 0bd3c45..07444af 100755 --- a/server/src/server/biome/BiomeChaos.java +++ b/server/src/server/biome/BiomeChaos.java @@ -38,7 +38,7 @@ public class BiomeChaos extends GenBiome { int i8 = rand.chOffset(); int l11 = rand.chOffset(); - BlockPos blockpos2 = worldIn.getHeight(pos.add(i8, 0, l11)); + BlockPos blockpos2 = worldIn.getPrecipitationHeight(pos.add(i8, 0, l11)); this.mushroomBlueGen.generate(worldIn, rand, blockpos2); } } diff --git a/server/src/server/biome/BiomeDesert.java b/server/src/server/biome/BiomeDesert.java index 0171ff5..079692e 100755 --- a/server/src/server/biome/BiomeDesert.java +++ b/server/src/server/biome/BiomeDesert.java @@ -33,7 +33,7 @@ public class BiomeDesert extends GenBiome { int i = rand.chOffset(); int j = rand.chOffset(); - BlockPos blockpos = worldIn.getHeight(pos.add(i, 0, j)).up(); + BlockPos blockpos = worldIn.getPrecipitationHeight(pos.add(i, 0, j)).up(); (new WorldGenDesertWells()).generate(worldIn, rand, blockpos); } } diff --git a/server/src/server/biome/BiomeForest.java b/server/src/server/biome/BiomeForest.java index c0ecc14..f6a5ecc 100755 --- a/server/src/server/biome/BiomeForest.java +++ b/server/src/server/biome/BiomeForest.java @@ -134,7 +134,7 @@ public class BiomeForest extends GenBiome { int k = i * 4 + rand.range(9, 11); int l = j * 4 + rand.range(9, 11); - BlockPos blockpos = worldIn.getHeight(pos.add(k, 0, l)); + BlockPos blockpos = worldIn.getPrecipitationHeight(pos.add(k, 0, l)); if (rand.chance(20)) { @@ -183,7 +183,7 @@ public class BiomeForest extends GenBiome { int j2 = rand.chOffset(); int k2 = rand.chOffset(); - int i1 = rand.zrange(worldIn.getHeight(pos.add(j2, 0, k2)).getY() + 32); + int i1 = rand.zrange(worldIn.getPrecipitationHeight(pos.add(j2, 0, k2)).getY() + 32); if (DOUBLE_PLANT_GEN.generate(worldIn, rand, new BlockPos(pos.getX() + j2, i1, pos.getZ() + k2))) { diff --git a/server/src/server/biome/BiomeJungle.java b/server/src/server/biome/BiomeJungle.java index e871913..8431daa 100755 --- a/server/src/server/biome/BiomeJungle.java +++ b/server/src/server/biome/BiomeJungle.java @@ -69,7 +69,7 @@ public class BiomeJungle extends GenBiome super.decorate(worldIn, rand, pos); int i = rand.chOffset(); int j = rand.chOffset(); - int k = rand.zrange(worldIn.getHeight(pos.add(i, 0, j)).getY() * 2); + int k = rand.zrange(worldIn.getPrecipitationHeight(pos.add(i, 0, j)).getY() * 2); (new WorldGenMelon()).generate(worldIn, rand, pos.add(i, k, j)); WorldGenVines worldgenvines = new WorldGenVines(); diff --git a/server/src/server/biome/BiomePlains.java b/server/src/server/biome/BiomePlains.java index 2732ac8..45ce1f0 100755 --- a/server/src/server/biome/BiomePlains.java +++ b/server/src/server/biome/BiomePlains.java @@ -87,7 +87,7 @@ public class BiomePlains extends GenBiome { int j = rand.chOffset(); int k = rand.chOffset(); - int l = rand.zrange(worldIn.getHeight(pos.add(j, 0, k)).getY() + 32); + int l = rand.zrange(worldIn.getPrecipitationHeight(pos.add(j, 0, k)).getY() + 32); DOUBLE_PLANT_GEN.generate(worldIn, rand, pos.add(j, l, k)); } } @@ -101,7 +101,7 @@ public class BiomePlains extends GenBiome // { int j1 = rand.chOffset(); int k1 = rand.chOffset(); - int l1 = rand.zrange(worldIn.getHeight(pos.add(j1, 0, k1)).getY() + 32); + int l1 = rand.zrange(worldIn.getPrecipitationHeight(pos.add(j1, 0, k1)).getY() + 32); DOUBLE_PLANT_GEN.generate(worldIn, rand, pos.add(j1, l1, k1)); // } } diff --git a/server/src/server/biome/BiomeSavanna.java b/server/src/server/biome/BiomeSavanna.java index 1063529..c8b3776 100755 --- a/server/src/server/biome/BiomeSavanna.java +++ b/server/src/server/biome/BiomeSavanna.java @@ -46,7 +46,7 @@ public class BiomeSavanna extends GenBiome { int j = rand.chOffset(); int k = rand.chOffset(); - int l = rand.zrange(worldIn.getHeight(pos.add(j, 0, k)).getY() + 32); + int l = rand.zrange(worldIn.getPrecipitationHeight(pos.add(j, 0, k)).getY() + 32); DOUBLE_PLANT_GEN.generate(worldIn, rand, pos.add(j, l, k)); } diff --git a/server/src/server/biome/BiomeSnow.java b/server/src/server/biome/BiomeSnow.java index ea236f2..e3e1d94 100755 --- a/server/src/server/biome/BiomeSnow.java +++ b/server/src/server/biome/BiomeSnow.java @@ -36,14 +36,14 @@ public class BiomeSnow extends GenBiome { int j = rand.chOffset(); int k = rand.chOffset(); - this.spikeGen.generate(worldIn, rand, worldIn.getHeight(pos.add(j, 0, k))); + this.spikeGen.generate(worldIn, rand, worldIn.getPrecipitationHeight(pos.add(j, 0, k))); } for (int l = 0; l < 2; ++l) { int i1 = rand.chOffset(); int j1 = rand.chOffset(); - this.pathGen.generate(worldIn, rand, worldIn.getHeight(pos.add(i1, 0, j1))); + this.pathGen.generate(worldIn, rand, worldIn.getPrecipitationHeight(pos.add(i1, 0, j1))); } } diff --git a/server/src/server/biome/BiomeTaiga.java b/server/src/server/biome/BiomeTaiga.java index d7a9c5f..4d9fbc6 100755 --- a/server/src/server/biome/BiomeTaiga.java +++ b/server/src/server/biome/BiomeTaiga.java @@ -70,7 +70,7 @@ public class BiomeTaiga extends GenBiome { int k = rand.chOffset(); int l = rand.chOffset(); - BlockPos blockpos = worldIn.getHeight(pos.add(k, 0, l)); + BlockPos blockpos = worldIn.getPrecipitationHeight(pos.add(k, 0, l)); field_150643_aG.generate(worldIn, rand, blockpos); } } @@ -81,7 +81,7 @@ public class BiomeTaiga extends GenBiome { int j1 = rand.chOffset(); int k1 = rand.chOffset(); - int l1 = rand.zrange(worldIn.getHeight(pos.add(j1, 0, k1)).getY() + 32); + int l1 = rand.zrange(worldIn.getPrecipitationHeight(pos.add(j1, 0, k1)).getY() + 32); DOUBLE_PLANT_GEN.generate(worldIn, rand, pos.add(j1, l1, k1)); } diff --git a/server/src/server/biome/BiomeTian.java b/server/src/server/biome/BiomeTian.java index 58c7d45..5f05ad9 100755 --- a/server/src/server/biome/BiomeTian.java +++ b/server/src/server/biome/BiomeTian.java @@ -68,7 +68,7 @@ public class BiomeTian extends GenBiome { int i8 = rand.chOffset(); int l11 = rand.chOffset(); - BlockPos blockpos2 = worldIn.getHeight(pos.add(i8, 0, l11)); + BlockPos blockpos2 = worldIn.getPrecipitationHeight(pos.add(i8, 0, l11)); this.mushroomBlueGen.generate(worldIn, rand, blockpos2); } } diff --git a/server/src/server/biome/GenBiome.java b/server/src/server/biome/GenBiome.java index 825b630..f87a088 100755 --- a/server/src/server/biome/GenBiome.java +++ b/server/src/server/biome/GenBiome.java @@ -340,7 +340,7 @@ public abstract class GenBiome implements IBiome { int l = rand.chOffset(); WorldGenTree treeGen = this.genBigTreeChance(rand); treeGen.prepare(); - BlockPos blockpos = world.getHeight(pos.add(k6, 0, l)); + BlockPos blockpos = world.getPrecipitationHeight(pos.add(k6, 0, l)); if (treeGen.generate(world, rand, blockpos)) { @@ -352,14 +352,14 @@ public abstract class GenBiome implements IBiome { { int l6 = rand.chOffset(); int k10 = rand.chOffset(); - this.bigMushroomGen.generate(world, rand, world.getHeight(pos.add(l6, 0, k10))); + this.bigMushroomGen.generate(world, rand, world.getPrecipitationHeight(pos.add(l6, 0, k10))); } for (int l2 = 0; l2 < this.flowersPerChunk; ++l2) { int i7 = rand.chOffset(); int l10 = rand.chOffset(); - int j14 = world.getHeight(pos.add(i7, 0, l10)).getY() + 32; + int j14 = world.getPrecipitationHeight(pos.add(i7, 0, l10)).getY() + 32; if (j14 > 0) { @@ -380,7 +380,7 @@ public abstract class GenBiome implements IBiome { { int j7 = rand.chOffset(); int i11 = rand.chOffset(); - int k14 = world.getHeight(pos.add(j7, 0, i11)).getY() * 2; + int k14 = world.getPrecipitationHeight(pos.add(j7, 0, i11)).getY() * 2; if (k14 > 0) { @@ -393,7 +393,7 @@ public abstract class GenBiome implements IBiome { { int k7 = rand.chOffset(); int j11 = rand.chOffset(); - int l14 = world.getHeight(pos.add(k7, 0, j11)).getY() * 2; + int l14 = world.getPrecipitationHeight(pos.add(k7, 0, j11)).getY() * 2; if (l14 > 0) { @@ -406,7 +406,7 @@ public abstract class GenBiome implements IBiome { { int l7 = rand.chOffset(); int k11 = rand.chOffset(); - int i15 = world.getHeight(pos.add(l7, 0, k11)).getY() * 2; + int i15 = world.getPrecipitationHeight(pos.add(l7, 0, k11)).getY() * 2; if (i15 > 0) { @@ -434,7 +434,7 @@ public abstract class GenBiome implements IBiome { { int i8 = rand.chOffset(); int l11 = rand.chOffset(); - BlockPos blockpos2 = world.getHeight(pos.add(i8, 0, l11)); + BlockPos blockpos2 = world.getPrecipitationHeight(pos.add(i8, 0, l11)); this.mushroomBrownGen.generate(world, rand, blockpos2); } @@ -442,7 +442,7 @@ public abstract class GenBiome implements IBiome { { int j8 = rand.chOffset(); int i12 = rand.chOffset(); - int j15 = world.getHeight(pos.add(j8, 0, i12)).getY() * 2; + int j15 = world.getPrecipitationHeight(pos.add(j8, 0, i12)).getY() * 2; if (j15 > 0) { @@ -457,7 +457,7 @@ public abstract class GenBiome implements IBiome { { int i4 = rand.chOffset(); int k8 = rand.chOffset(); - int j12 = world.getHeight(pos.add(i4, 0, k8)).getY() * 2; + int j12 = world.getPrecipitationHeight(pos.add(i4, 0, k8)).getY() * 2; if (j12 > 0) { @@ -470,7 +470,7 @@ public abstract class GenBiome implements IBiome { { int j4 = rand.chOffset(); int l8 = rand.chOffset(); - int k12 = world.getHeight(pos.add(j4, 0, l8)).getY() * 2; + int k12 = world.getPrecipitationHeight(pos.add(j4, 0, l8)).getY() * 2; if (k12 > 0) { @@ -483,7 +483,7 @@ public abstract class GenBiome implements IBiome { { int i9 = rand.chOffset(); int l12 = rand.chOffset(); - int i16 = world.getHeight(pos.add(i9, 0, l12)).getY() * 2; + int i16 = world.getPrecipitationHeight(pos.add(i9, 0, l12)).getY() * 2; if (i16 > 0) { @@ -496,7 +496,7 @@ public abstract class GenBiome implements IBiome { { int j9 = rand.chOffset(); int i13 = rand.chOffset(); - int j16 = world.getHeight(pos.add(j9, 0, i13)).getY() * 2; + int j16 = world.getPrecipitationHeight(pos.add(j9, 0, i13)).getY() * 2; if (j16 > 0) { @@ -509,7 +509,7 @@ public abstract class GenBiome implements IBiome { { int i5 = rand.chOffset(); int k9 = rand.chOffset(); - int j13 = world.getHeight(pos.add(i5, 0, k9)).getY() * 2; + int j13 = world.getPrecipitationHeight(pos.add(i5, 0, k9)).getY() * 2; if (j13 > 0) { @@ -522,7 +522,7 @@ public abstract class GenBiome implements IBiome { { int l9 = rand.chOffset(); int k13 = rand.chOffset(); - int l16 = world.getHeight(pos.add(l9, 0, k13)).getY() * 2; + int l16 = world.getPrecipitationHeight(pos.add(l9, 0, k13)).getY() * 2; if (l16 > 0) { diff --git a/server/src/server/village/VillageCollection.java b/server/src/server/village/VillageCollection.java index 53ad125..4730732 100755 --- a/server/src/server/village/VillageCollection.java +++ b/server/src/server/village/VillageCollection.java @@ -215,15 +215,16 @@ public class VillageCollection for (int j = 1; j <= 5; ++j) { - if (world.canSeeSky(centerPos.offset(direction, j))) - { - ++i; - - if (i >= limitation) - { - return i; + BlockPos pos = centerPos.offset(direction, j); + for(int z = 0; z < 5; z++) { + if(!world.isAirBlock(pos.up(z))) + break; + if(z == 4) { + ++i; + if(i >= limitation) + return i; } - } + } } return i; diff --git a/server/src/server/world/Region.java b/server/src/server/world/Region.java index b74566d..de680a3 100755 --- a/server/src/server/world/Region.java +++ b/server/src/server/world/Region.java @@ -370,7 +370,6 @@ public class Region { return null; } Chunk chunk = new Chunk(world, x, z); - chunk.setHeights(tag.getIntArray("HeightMap")); chunk.setTerrainPopulated(tag.getBoolean("TerrainPopulated")); chunk.setInhabited(tag.getLong("InhabitedTime")); NBTTagList sects = tag.getTagList("Sections", 10); @@ -484,7 +483,6 @@ public class Region { NBTTagCompound tag = new NBTTagCompound(); // tag.setShort("V", (short)Config.PROTOCOL); tag.setLong("LastUpdate", world.getTime()); - tag.setIntArray("HeightMap", chunk.getHeights()); tag.setBoolean("TerrainPopulated", chunk.isTerrainPopulated()); tag.setLong("InhabitedTime", chunk.getInhabited()); BlockArray[] sections = chunk.getStorage(); diff --git a/server/src/server/world/Spawner.java b/server/src/server/world/Spawner.java index 5133cf3..02f27ff 100755 --- a/server/src/server/world/Spawner.java +++ b/server/src/server/world/Spawner.java @@ -14,7 +14,6 @@ import common.rng.WeightedList; import common.util.BlockPos; import common.util.ChunkPos; import common.util.ExtMath; -import common.world.Chunk; import common.world.World; import server.biome.GenBiome; import server.biome.RngSpawn; @@ -87,15 +86,14 @@ public abstract class Spawner { if(cur <= max) { typeLabel: for(ChunkPos coord : CHUNKS) { - Chunk chunk = world.getChunk(coord.x, coord.z); int x = coord.x * 16 + world.rand.zrange(16); int z = coord.z * 16 + world.rand.zrange(16); - int h = chunk.getHeight(new BlockPos(x, 0, z)) + 1; + int h = world.getPrecipitationHeight(new BlockPos(x, 0, z)).getY() + 1; if(h > 0) { int m = h % 16; h = m == 0 ? h : h + 16 - m; } - h = h == 0 ? 16 : (h > 0 ? h : chunk.getTopSegment() + 16 - 1); + h = h <= 0 ? 16 : h; int y = world.rand.excl(h <= 8 ? 0 : 8, h); BlockPos pos = new BlockPos(x, y, z); Block block = world.getState(pos).getBlock(); diff --git a/server/src/server/world/WorldServer.java b/server/src/server/world/WorldServer.java index 73d7743..ae195e8 100755 --- a/server/src/server/world/WorldServer.java +++ b/server/src/server/world/WorldServer.java @@ -744,7 +744,7 @@ public final class WorldServer extends AWorldServer { 3.0D, 3.0D); List list = this.getEntitiesWithinAABB(EntityLiving.class, axisalignedbb, new Predicate() { public boolean test(EntityLiving p_apply_1_) { - return p_apply_1_ != null && p_apply_1_.isEntityAlive() && WorldServer.this.canSeeSky(p_apply_1_.getPosition()); + return p_apply_1_ != null && p_apply_1_.isEntityAlive() && p_apply_1_.getPosition().getY() >= blockpos.getY(); } }); return !list.isEmpty() ? ((EntityLiving)list.get(this.rand.zrange(list.size()))).getPosition() : blockpos; @@ -2303,10 +2303,7 @@ public final class WorldServer extends AWorldServer { } public boolean canStrikeAt(BlockPos strikePosition) { - if(!this.canSeeSky(strikePosition)) { - return false; - } - else if(this.getPrecipitationHeight(strikePosition).getY() > strikePosition.getY()) { + if(this.getPrecipitationHeight(strikePosition).getY() > strikePosition.getY()) { return false; } return true; @@ -2427,12 +2424,13 @@ public final class WorldServer extends AWorldServer { return false; } - public BlockPos getTopSolidOrLiquidBlock(BlockPos pos) { + public BlockPos getTopSolidOrLiquidBlock(BlockPos pos, int y, int scan) { + scan = y - scan; Chunk chunk = this.getChunk(pos); BlockPos blockpos; BlockPos blockpos1; - for(blockpos = new BlockPos(pos.getX(), chunk.getTopSegment() + 16, pos.getZ()); blockpos.getY() >= 0; blockpos = blockpos1) { + for(blockpos = new BlockPos(pos.getX(), y, pos.getZ()); blockpos.getY() >= 0 && blockpos.getY() >= scan; blockpos = blockpos1) { blockpos1 = blockpos.down(); Material material = chunk.getBlock(blockpos1).getMaterial(); @@ -2444,6 +2442,10 @@ public final class WorldServer extends AWorldServer { return blockpos; } + public BlockPos getTopSolidOrLiquidBlock(BlockPos pos) { + return this.getTopSolidOrLiquidBlock(pos, 256, 256); + } + public void removePlayerEntityDangerously(Entity entityIn) { entityIn.setDead();