remove chunk height

This commit is contained in:
Sen 2025-05-19 16:34:44 +02:00
parent aa772848ed
commit 6aae6f32e4
24 changed files with 75 additions and 398 deletions

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
}
}

View file

@ -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);
}
}

View file

@ -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()

View file

@ -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;

View file

@ -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

View file

@ -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;
}
}

View file

@ -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<BlockPos, TileEntity> tiles = Maps.<BlockPos, TileEntity>newHashMap();
private final ClassInheritanceMultiMap<Entity>[] entities = new ClassInheritanceMultiMap[32];
private final ConcurrentLinkedQueue<BlockPos> tileQueue = new ConcurrentLinkedQueue<BlockPos>();
@ -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<BlockPos, TileEntity> 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;
}

View file

@ -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);

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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)))
{

View file

@ -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();

View file

@ -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));
// }
}

View file

@ -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));
}

View file

@ -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)));
}
}

View file

@ -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));
}

View file

@ -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);
}
}

View file

@ -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)
{

View file

@ -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;

View file

@ -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();

View file

@ -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();

View file

@ -744,7 +744,7 @@ public final class WorldServer extends AWorldServer {
3.0D, 3.0D);
List<EntityLiving> list = this.getEntitiesWithinAABB(EntityLiving.class, axisalignedbb, new Predicate<EntityLiving>() {
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();