Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8f0c0f7170 |
30 changed files with 491 additions and 1563 deletions
|
@ -157,7 +157,6 @@ import common.util.LazyLoadBase;
|
|||
import common.util.Util;
|
||||
import common.util.HitPosition.ObjectType;
|
||||
import common.world.Chunk;
|
||||
import common.world.LightType;
|
||||
import common.world.State;
|
||||
import common.world.World;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
|
@ -1730,30 +1729,22 @@ public class Client implements IThreadListener {
|
|||
break;
|
||||
}
|
||||
|
||||
Biome biome = null;
|
||||
String bline;
|
||||
String lline;
|
||||
String light;
|
||||
if(this.world.isBlockLoaded(blockpos)) {
|
||||
Chunk chunk = this.world.getChunk(blockpos);
|
||||
biome = chunk.getBiome(blockpos, null);
|
||||
bline = "Biom: " + biome.display + " (" + biome.id + ")" + /* (this.debugHideInfo ? "" : */ (", D: " +
|
||||
TextColor.stripCodes(this.world.dimension.getFormattedName(false)) +
|
||||
" (" + this.world.dimension.getDimensionId() + ")");
|
||||
lline = "Licht: " + chunk.getLightSub(blockpos, 0) + " (" + chunk.getLight(LightType.SKY, blockpos) + " Himmel, "
|
||||
+ chunk.getLight(LightType.BLOCK, blockpos) + " Blöcke, " + String.format(
|
||||
light = "Licht: " + chunk.getLightSub(blockpos, 0) + " ("
|
||||
+ chunk.getLight(blockpos) + " Blöcke, " + String.format(
|
||||
"%.1f", this.world.getSunBrightness(1.0f) * 15.0f) + " Welt), A: "
|
||||
+ String.format("%.3f", this.world.getCelestialAngle(1.0f));
|
||||
}
|
||||
else {
|
||||
bline = "Biom: <?>, D: " +
|
||||
TextColor.stripCodes(this.world.dimension.getFormattedName(false)) +
|
||||
" (" + this.world.dimension.getDimensionId() + ")";
|
||||
lline = "Licht: " + String.format(
|
||||
light = "Licht: " + String.format(
|
||||
"%.1f", this.world.getSunBrightness(1.0f) * 15.0f) + " Welt, A: "
|
||||
+ String.format("%.3f", this.world.getCelestialAngle(1.0f));
|
||||
}
|
||||
|
||||
float temp = this.world.getTempOffset() + (biome != null ? biome.getTemperature(blockpos) : 0.0f);
|
||||
float temp = this.world.getTemperatureK(blockpos);
|
||||
Biome biome = this.world.getBiomeGenForCoords(blockpos);
|
||||
long ticked = System.currentTimeMillis() - this.lastTicked;
|
||||
|
||||
return
|
||||
|
@ -1778,8 +1769,10 @@ public class Client implements IThreadListener {
|
|||
String.format(" (Zoom x%.1f)", this.zoomLevel) : "") + "\n" +
|
||||
String.format("Richtung: %s (%.1f / %.1f)", dirStr,
|
||||
ExtMath.wrapf(entity.rotYaw), ExtMath.wrapf(entity.rotPitch)) + "\n" +
|
||||
bline + "\n" +
|
||||
lline + "\n" +
|
||||
"Biom: " + biome.display + " (" + biome.id + ")" + (", D: " +
|
||||
TextColor.stripCodes(this.world.dimension.getFormattedName(false)) +
|
||||
" (" + this.world.dimension.getDimensionId() + ")") + "\n" +
|
||||
light + "\n" +
|
||||
String.format("Zeit: %d T, R %d / %d T, U %d / %d T",
|
||||
this.world.getDayTime(),
|
||||
this.world.getDayTime() % this.world.dimension.getRotationalPeriod(),
|
||||
|
|
|
@ -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.getHeight(blockpos.add(this.random.zrange(i) - this.random.zrange(i), 0, this.random.zrange(i) - this.random.zrange(i)));
|
||||
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.getHeight(blockpos).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.getHeight(blockpos$mutableblockpos).getY();
|
||||
int k2 = j - i1;
|
||||
int l2 = j + i1;
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import common.util.Vec3i;
|
|||
import common.world.Chunk;
|
||||
import common.world.ChunkCache;
|
||||
import common.world.IWorldAccess;
|
||||
import common.world.LightType;
|
||||
import common.world.State;
|
||||
import common.world.World;
|
||||
|
||||
|
@ -32,14 +31,16 @@ public class RegionRenderCache extends ChunkCache implements IWorldAccess
|
|||
boolean empty = true;
|
||||
for (int i1 = posFromIn.getX() >> 4; i1 <= posToIn.getX() >> 4; ++i1)
|
||||
{
|
||||
for (int j1 = posFromIn.getZ() >> 4; j1 <= posToIn.getZ() >> 4; ++j1)
|
||||
{
|
||||
Chunk chunk = this.chunkArray[i1 - this.chunkX][j1 - this.chunkZ];
|
||||
|
||||
if (chunk != null && !chunk.isEmpty(posFromIn.getY(), posToIn.getY()))
|
||||
{
|
||||
empty = false;
|
||||
}
|
||||
for (int n1 = posFromIn.getY() >> 4; n1 <= posToIn.getY() >> 4; ++n1) {
|
||||
for (int j1 = posFromIn.getZ() >> 4; j1 <= posToIn.getZ() >> 4; ++j1)
|
||||
{
|
||||
Chunk chunk = this.chunkArray[i1 - this.chunkX][n1 - this.chunkY][j1 - this.chunkZ];
|
||||
|
||||
if (chunk != null && !chunk.isEmpty())
|
||||
{
|
||||
empty = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.empty = empty;
|
||||
|
@ -53,8 +54,9 @@ public class RegionRenderCache extends ChunkCache implements IWorldAccess
|
|||
public TileEntity getTileEntity(BlockPos pos)
|
||||
{
|
||||
int i = (pos.getX() >> 4) - this.chunkX;
|
||||
int n = (pos.getY() >> 4) - this.chunkY;
|
||||
int j = (pos.getZ() >> 4) - this.chunkZ;
|
||||
return this.chunkArray[i][j].getTileEntity(pos, TileEntity.EnumCreateEntityType.QUEUED);
|
||||
return this.chunkArray[i][n][j].getTileEntity(pos, TileEntity.EnumCreateEntityType.QUEUED);
|
||||
}
|
||||
|
||||
public int getCombinedLight(BlockPos pos, int lightValue)
|
||||
|
@ -87,16 +89,10 @@ public class RegionRenderCache extends ChunkCache implements IWorldAccess
|
|||
|
||||
private State getBlockStateRaw(BlockPos pos)
|
||||
{
|
||||
if (pos.getY() >= 0 && pos.getY() < 512)
|
||||
{
|
||||
int i = (pos.getX() >> 4) - this.chunkX;
|
||||
int j = (pos.getZ() >> 4) - this.chunkZ;
|
||||
return this.chunkArray[i][j].getState(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
return DEFAULT_STATE;
|
||||
}
|
||||
int i = (pos.getX() >> 4) - this.chunkX;
|
||||
int n = (pos.getY() >> 4) - this.chunkY;
|
||||
int j = (pos.getZ() >> 4) - this.chunkZ;
|
||||
return this.chunkArray[i][n][j].getState(pos);
|
||||
}
|
||||
|
||||
private int getPositionIndex(BlockPos p_175630_1_)
|
||||
|
@ -114,15 +110,14 @@ public class RegionRenderCache extends ChunkCache implements IWorldAccess
|
|||
|
||||
public int getLight(BlockPos pos, int lightValue)
|
||||
{
|
||||
int i = this.getLightForExt(LightType.SKY, pos);
|
||||
int j = this.getLightForExt(LightType.BLOCK, pos);
|
||||
int j = this.getLightForExt(pos);
|
||||
|
||||
if (j < lightValue)
|
||||
{
|
||||
j = lightValue;
|
||||
}
|
||||
|
||||
return i << 20 | j << 4;
|
||||
return 15 << 20 | j << 4;
|
||||
}
|
||||
|
||||
public Biome getBiomeGenForCoords(BlockPos pos)
|
||||
|
@ -130,74 +125,43 @@ public class RegionRenderCache extends ChunkCache implements IWorldAccess
|
|||
return this.worldObj.getBiomeGenForCoords(pos);
|
||||
}
|
||||
|
||||
private int getLightForExt(LightType p_175629_1_, BlockPos pos)
|
||||
private int getLightForExt(BlockPos pos)
|
||||
{
|
||||
if (p_175629_1_ == LightType.SKY && this.worldObj.dimension.hasNoLight())
|
||||
if (this.getState(pos).getBlock().getSumBrightness())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (pos.getY() >= 0 && pos.getY() < 512)
|
||||
{
|
||||
if (this.getState(pos).getBlock().getSumBrightness())
|
||||
int l = 0;
|
||||
|
||||
for (Facing enumfacing : Facing.values())
|
||||
{
|
||||
int l = 0;
|
||||
int k = this.getLightFor(pos.offset(enumfacing));
|
||||
|
||||
for (Facing enumfacing : Facing.values())
|
||||
if (k > l)
|
||||
{
|
||||
int k = this.getLightFor(p_175629_1_, pos.offset(enumfacing));
|
||||
|
||||
if (k > l)
|
||||
{
|
||||
l = k;
|
||||
}
|
||||
|
||||
if (l >= 15)
|
||||
{
|
||||
return l;
|
||||
}
|
||||
l = k;
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = (pos.getX() >> 4) - this.chunkX;
|
||||
int j = (pos.getZ() >> 4) - this.chunkZ;
|
||||
return this.chunkArray[i][j].getLight(p_175629_1_, pos);
|
||||
if (l >= 15)
|
||||
{
|
||||
return l;
|
||||
}
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
else
|
||||
{
|
||||
return p_175629_1_.defValue;
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Checks to see if an air block exists at the provided location. Note that this only checks to see if the blocks
|
||||
// * material is set to air, meaning it is possible for non-vanilla blocks to still pass this check.
|
||||
// */
|
||||
// public boolean isAirBlock(BlockPos pos)
|
||||
// {
|
||||
// return this.getBlockState(pos).getBlock().getMaterial() == Material.air;
|
||||
// }
|
||||
|
||||
public int getLightFor(LightType p_175628_1_, BlockPos pos)
|
||||
{
|
||||
if (pos.getY() >= 0 && pos.getY() < 512)
|
||||
{
|
||||
int i = (pos.getX() >> 4) - this.chunkX;
|
||||
int n = (pos.getX() >> 4) - this.chunkY;
|
||||
int j = (pos.getZ() >> 4) - this.chunkZ;
|
||||
return this.chunkArray[i][j].getLight(p_175628_1_, pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
return p_175628_1_.defValue;
|
||||
return this.chunkArray[i][n][j].getLight(pos);
|
||||
}
|
||||
}
|
||||
|
||||
// public int getStrongPower(BlockPos pos, EnumFacing direction)
|
||||
// {
|
||||
// IBlockState iblockstate = this.getBlockState(pos);
|
||||
// return iblockstate.getBlock().getStrongPower(this, pos, iblockstate, direction);
|
||||
// }
|
||||
|
||||
public int getLightFor(BlockPos pos)
|
||||
{
|
||||
int i = (pos.getX() >> 4) - this.chunkX;
|
||||
int n = (pos.getY() >> 4) - this.chunkY;
|
||||
int j = (pos.getZ() >> 4) - this.chunkZ;
|
||||
return this.chunkArray[i][n][j].getLight(pos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,21 +10,10 @@ import common.tileentity.TileEntity;
|
|||
import common.util.BlockPos;
|
||||
import common.util.BoundingBox;
|
||||
import common.world.Chunk;
|
||||
import common.world.LightType;
|
||||
|
||||
public class EmptyChunk extends Chunk {
|
||||
public EmptyChunk(WorldClient world) {
|
||||
super(world, 0, 0);
|
||||
}
|
||||
|
||||
public int getHeight(int x, int z) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void genHeights() {
|
||||
}
|
||||
|
||||
public void genSkyLight() {
|
||||
super(world, 0, 0, 0);
|
||||
}
|
||||
|
||||
public Block getBlock(BlockPos pos) {
|
||||
|
@ -39,11 +28,11 @@ public class EmptyChunk extends Chunk {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public int getLight(LightType type, BlockPos pos) {
|
||||
return type.defValue;
|
||||
public int getLight(BlockPos pos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setLight(LightType type, BlockPos pos, int value) {
|
||||
public void setLight(BlockPos pos, int value) {
|
||||
}
|
||||
|
||||
public int getLightSub(BlockPos pos, int amount) {
|
||||
|
@ -56,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;
|
||||
}
|
||||
|
@ -88,15 +73,15 @@ public class EmptyChunk extends Chunk {
|
|||
public <T extends Entity> void getEntities(Class<? extends T> clazz, BoundingBox bb, List<T> list, Predicate<? super T> pred) {
|
||||
}
|
||||
|
||||
public boolean isDirty() {
|
||||
public boolean isDirty(long time) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isDummy() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isEmpty(int bottom, int top) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ public class WorldClient extends AWorldClient
|
|||
else
|
||||
{
|
||||
Chunk chunk = this.getChunk(x, z);
|
||||
if (!chunk.isEmpty())
|
||||
if (!chunk.isDummy())
|
||||
{
|
||||
chunk.onChunkUnload();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
|
|
|
@ -21,7 +21,6 @@ import common.util.BlockPos;
|
|||
import common.util.ExtMath;
|
||||
import common.util.Facing;
|
||||
import common.world.IWorldAccess;
|
||||
import common.world.LightType;
|
||||
import common.world.State;
|
||||
import common.world.World;
|
||||
import common.world.AWorldServer;
|
||||
|
@ -58,7 +57,7 @@ public class BlockDaylightDetector extends BlockContainer
|
|||
if (!worldIn.dimension.hasNoLight())
|
||||
{
|
||||
State iblockstate = worldIn.getState(pos);
|
||||
int i = worldIn.getLightFor(LightType.SKY, pos) - worldIn.getSkylightSubtracted();
|
||||
int i = 15 - worldIn.getSkylightSubtracted();
|
||||
float f = worldIn.getCelestialAngleRadians(1.0F);
|
||||
float f1 = f < (float)Math.PI ? 0.0F : ((float)Math.PI * 2F);
|
||||
f = f + (f1 - f) * 0.2F;
|
||||
|
|
|
@ -11,7 +11,6 @@ import common.model.BlockLayer;
|
|||
import common.rng.Random;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.util.BlockPos;
|
||||
import common.world.LightType;
|
||||
import common.world.State;
|
||||
import common.world.World;
|
||||
import common.world.AWorldServer;
|
||||
|
@ -73,7 +72,7 @@ public class BlockIce extends BlockBreakable
|
|||
|
||||
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
|
||||
{
|
||||
if (Config.iceMelt && ((worldIn.getLightFor(LightType.BLOCK, pos) > 11 - this.getLightOpacity()) || !worldIn.canFreezeAt(pos)))
|
||||
if (Config.iceMelt && ((worldIn.getLightFor(pos) > 11 - this.getLightOpacity()) || !worldIn.canFreezeAt(pos)))
|
||||
{
|
||||
if (worldIn.doesWaterVaporize(pos))
|
||||
{
|
||||
|
|
|
@ -20,7 +20,6 @@ import common.util.BoundingBox;
|
|||
import common.util.Facing;
|
||||
import common.world.IBlockAccess;
|
||||
import common.world.IWorldAccess;
|
||||
import common.world.LightType;
|
||||
import common.world.State;
|
||||
import common.world.World;
|
||||
import common.world.AWorldServer;
|
||||
|
@ -137,7 +136,7 @@ public class BlockSnow extends Block
|
|||
|
||||
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
|
||||
{
|
||||
if (Config.snowMelt && ((worldIn.getLightFor(LightType.BLOCK, pos) > 11) || !worldIn.canFreezeAt(pos)))
|
||||
if (Config.snowMelt && ((worldIn.getLightFor(pos) > 11) || !worldIn.canFreezeAt(pos)))
|
||||
{
|
||||
this.dropBlockAsItem(worldIn, pos, worldIn.getState(pos), 0);
|
||||
worldIn.setBlockToAir(pos);
|
||||
|
|
|
@ -7,7 +7,6 @@ import common.item.Item;
|
|||
import common.material.Material;
|
||||
import common.rng.Random;
|
||||
import common.util.BlockPos;
|
||||
import common.world.LightType;
|
||||
import common.world.State;
|
||||
import common.world.AWorldServer;
|
||||
|
||||
|
@ -38,7 +37,7 @@ public class BlockSnowBlock extends Block
|
|||
|
||||
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
|
||||
{
|
||||
if (Config.snowFullMelt && worldIn.getLightFor(LightType.BLOCK, pos) > 11)
|
||||
if (Config.snowFullMelt && worldIn.getLightFor(pos) > 11)
|
||||
{
|
||||
this.dropBlockAsItem(worldIn, pos, worldIn.getState(pos), 0);
|
||||
worldIn.setBlockToAir(pos);
|
||||
|
|
|
@ -42,7 +42,7 @@ public class BlockTorch extends Block
|
|||
else {
|
||||
Chunk chunk = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
|
||||
|
||||
if(chunk.isEmpty()) {
|
||||
if(chunk.isDummy()) {
|
||||
return def;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -279,8 +279,6 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
private State alt1 = Blocks.air.getState(); // cavebase, r.biome, r.simple, r.alternate
|
||||
private State alt2 = Blocks.air.getState(); // r.simple, r.alternate
|
||||
private State liquid = Blocks.air.getState(); // g.perlin, g.cavern, g.simple, r.biome, r.simple, r.alternate
|
||||
private State floor = null; // chunk
|
||||
private State ceiling = null; // chunk
|
||||
private State caveFiller = Blocks.air.getState(); // cavebase, ravine
|
||||
private State[] layers = null; // g.flat
|
||||
private Biome[] frostBiomes = null; // b.layered
|
||||
|
@ -547,22 +545,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
this.dungeons = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Dimension setWorldFloor(State value) {
|
||||
this.floor = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Dimension setWorldCeiling(State value) {
|
||||
this.ceiling = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Dimension setWorldFloorCeiling(State value) {
|
||||
this.floor = this.ceiling = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public final Dimension enableStrongholds() {
|
||||
this.useStrongholds = true;
|
||||
return this;
|
||||
|
@ -843,15 +826,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
public final boolean hasSnow() {
|
||||
return this.snow;
|
||||
}
|
||||
|
||||
public final State getWorldFloor() {
|
||||
return this.floor;
|
||||
}
|
||||
|
||||
public final State getWorldCeiling() {
|
||||
return this.ceiling;
|
||||
}
|
||||
|
||||
|
||||
public final int getSeaLevel() {
|
||||
return this.seaLevel;
|
||||
}
|
||||
|
@ -1022,10 +997,6 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
this.alt1 = BlockRegistry.getFromIdName(tag.getString("AltBlock1"), Blocks.gravel.getState());
|
||||
this.alt2 = BlockRegistry.getFromIdName(tag.getString("AltBlock2"), Blocks.sand.getState());
|
||||
this.liquid = BlockRegistry.getFromIdName(tag.getString("LiquidBlock"), Blocks.water.getState());
|
||||
this.floor = tag.hasKey("FloorBlock", 8) ?
|
||||
BlockRegistry.getFromIdName(tag.getString("FloorBlock"), Blocks.bedrock.getState()) : null;
|
||||
this.ceiling = tag.hasKey("CeilingBlock", 8) ?
|
||||
BlockRegistry.getFromIdName(tag.getString("CeilingBlock"), null) : null;
|
||||
this.caveFiller = BlockRegistry.getFromIdName(tag.getString("CaveFillBlock"), Blocks.lava.getState());
|
||||
if(tag.hasKey("Layers", 9)) {
|
||||
NBTTagList list = tag.getTagList("Layers", 8);
|
||||
|
@ -1258,10 +1229,6 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
tag.setString("AltBlock1", BlockRegistry.toIdName(this.alt1));
|
||||
tag.setString("AltBlock2", BlockRegistry.toIdName(this.alt2));
|
||||
tag.setString("LiquidBlock", BlockRegistry.toIdName(this.liquid));
|
||||
if(this.floor != null)
|
||||
tag.setString("FloorBlock", BlockRegistry.toIdName(this.floor));
|
||||
if(this.ceiling != null)
|
||||
tag.setString("CeilingBlock", BlockRegistry.toIdName(this.ceiling));
|
||||
tag.setString("CaveFillBlock", BlockRegistry.toIdName(this.caveFiller));
|
||||
if(this.layers != null) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
|
|
@ -392,12 +392,7 @@ 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;
|
||||
|
|
|
@ -17,19 +17,17 @@ public class PathCache extends ChunkCache implements IBlockAccess
|
|||
|
||||
public State getState(BlockPos pos)
|
||||
{
|
||||
if (pos.getY() >= 0 && pos.getY() < 512)
|
||||
int i = (pos.getX() >> 4) - this.chunkX;
|
||||
int n = (pos.getY() >> 4) - this.chunkY;
|
||||
int j = (pos.getZ() >> 4) - this.chunkZ;
|
||||
|
||||
if (i >= 0 && i < this.chunkArray.length && n >= 0 && n < this.chunkArray[i].length && j >= 0 && j < this.chunkArray[i][n].length)
|
||||
{
|
||||
int i = (pos.getX() >> 4) - this.chunkX;
|
||||
int j = (pos.getZ() >> 4) - this.chunkZ;
|
||||
Chunk chunk = this.chunkArray[i][n][j];
|
||||
|
||||
if (i >= 0 && i < this.chunkArray.length && j >= 0 && j < this.chunkArray[i].length)
|
||||
if (chunk != null)
|
||||
{
|
||||
Chunk chunk = this.chunkArray[i][j];
|
||||
|
||||
if (chunk != null)
|
||||
{
|
||||
return chunk.getState(pos);
|
||||
}
|
||||
return chunk.getState(pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -322,13 +322,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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
@ -70,34 +69,7 @@ public class PathNavigateGround extends PathNavigate
|
|||
return (int)(this.theEntity.getEntityBoundingBox().minY + 0.5D);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,17 +2,20 @@ package common.util;
|
|||
|
||||
public class ChunkPos {
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int z;
|
||||
|
||||
public ChunkPos(int x, int z) {
|
||||
public ChunkPos(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int i = 1664525 * this.x + 1013904223;
|
||||
int j = 1664525 * (this.z ^ -559038737) + 1013904223;
|
||||
return i ^ j;
|
||||
int k = 1664525 * (this.y ^ -753653634) + 453434;
|
||||
return (i ^ j) + k;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
|
@ -24,11 +27,7 @@ public class ChunkPos {
|
|||
}
|
||||
else {
|
||||
ChunkPos pos = (ChunkPos)obj;
|
||||
return this.x == pos.x && this.z == pos.z;
|
||||
return this.x == pos.x && this.y == pos.y && this.z == pos.z;
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "[" + this.x + ", " + this.z + "]";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -390,11 +390,11 @@ int utf_len(const char *str) {
|
|||
return ((double)rtime()) / 1000000.0;
|
||||
}
|
||||
|
||||
public static String getRegionFolder(int x, int z) {
|
||||
return String.format("%c%03X%c%03X", x < 0 ? 'n' : 'p', ((x < 0) ? -x : x) >> 9, z < 0 ? 'n' : 'p', ((z < 0) ? -z : z) >> 9);
|
||||
public static String getRegionFolder(int x, int y, int z) {
|
||||
return String.format("%c%03X%c%03X%c%03X", x < 0 ? 'n' : 'p', ((x < 0) ? -x : x) >> 9, y < 0 ? 'n' : 'p', ((y < 0) ? -y : y) >> 9, z < 0 ? 'n' : 'p', ((z < 0) ? -z : z) >> 9);
|
||||
}
|
||||
|
||||
public static String getRegionName(int x, int z) {
|
||||
return String.format("r.%c%X%c%X.rgn", x < 0 ? 'n' : 'p', ((x < 0) ? -x : x) >> 3, z < 0 ? 'n' : 'p', ((z < 0) ? -z : z) >> 3);
|
||||
public static String getRegionName(int x, int y, int z) {
|
||||
return String.format("r.%c%X%c%X%c%X.rgn", x < 0 ? 'n' : 'p', ((x < 0) ? -x : x) >> 3, y < 0 ? 'n' : 'p', ((y < 0) ? -y : y) >> 3, z < 0 ? 'n' : 'p', ((z < 0) ? -z : z) >> 3);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,19 +6,14 @@ import common.init.Blocks;
|
|||
import common.util.NibbleArray;
|
||||
|
||||
public class BlockArray {
|
||||
private int yBase;
|
||||
private int blocks;
|
||||
private int ticked;
|
||||
private char[] data;
|
||||
private NibbleArray blocklight;
|
||||
private NibbleArray skylight;
|
||||
|
||||
public BlockArray(int y, boolean sky) {
|
||||
this.yBase = y;
|
||||
public BlockArray() {
|
||||
this.data = new char[4096];
|
||||
this.blocklight = new NibbleArray();
|
||||
if(sky)
|
||||
this.skylight = new NibbleArray();
|
||||
}
|
||||
|
||||
public State get(int x, int y, int z) {
|
||||
|
@ -59,19 +54,7 @@ public class BlockArray {
|
|||
public boolean isTicked() {
|
||||
return this.ticked > 0;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return this.yBase;
|
||||
}
|
||||
|
||||
public void setSky(int x, int y, int z, int value) {
|
||||
this.skylight.set(x, y, z, value);
|
||||
}
|
||||
|
||||
public int getSky(int x, int y, int z) {
|
||||
return this.skylight.get(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
public void setLight(int x, int y, int z, int value) {
|
||||
this.blocklight.set(x, y, z, value);
|
||||
}
|
||||
|
@ -105,10 +88,6 @@ public class BlockArray {
|
|||
return this.blocklight;
|
||||
}
|
||||
|
||||
public NibbleArray getSkylight() {
|
||||
return this.skylight;
|
||||
}
|
||||
|
||||
public void setData(char[] data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
@ -116,8 +95,4 @@ public class BlockArray {
|
|||
public void setBlocklight(NibbleArray data) {
|
||||
this.blocklight = data;
|
||||
}
|
||||
|
||||
public void setSkylight(NibbleArray data) {
|
||||
this.skylight = data;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -5,22 +5,28 @@ import common.util.BlockPos;
|
|||
public class ChunkCache
|
||||
{
|
||||
protected final int chunkX;
|
||||
protected final int chunkY;
|
||||
protected final int chunkZ;
|
||||
protected final Chunk[][] chunkArray;
|
||||
protected final Chunk[][][] chunkArray;
|
||||
|
||||
public ChunkCache(World worldIn, BlockPos posFromIn, BlockPos posToIn, int subIn)
|
||||
{
|
||||
this.chunkX = posFromIn.getX() - subIn >> 4;
|
||||
this.chunkY = posFromIn.getY() - subIn >> 4;
|
||||
this.chunkZ = posFromIn.getZ() - subIn >> 4;
|
||||
int i = posToIn.getX() + subIn >> 4;
|
||||
int n = posToIn.getY() + subIn >> 4;
|
||||
int j = posToIn.getZ() + subIn >> 4;
|
||||
this.chunkArray = new Chunk[i - this.chunkX + 1][j - this.chunkZ + 1];
|
||||
this.chunkArray = new Chunk[i - this.chunkX + 1][n - this.chunkY + 1][j - this.chunkZ + 1];
|
||||
|
||||
for (int k = this.chunkX; k <= i; ++k)
|
||||
{
|
||||
for (int l = this.chunkZ; l <= j; ++l)
|
||||
for (int m = this.chunkY; m <= n; ++m)
|
||||
{
|
||||
this.chunkArray[k - this.chunkX][l - this.chunkZ] = worldIn.getChunk(k, l);
|
||||
for (int l = this.chunkZ; l <= j; ++l)
|
||||
{
|
||||
this.chunkArray[k - this.chunkX][m - this.chunkY][l - this.chunkZ] = worldIn.getChunk(k, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
package common.world;
|
||||
|
||||
public enum LightType {
|
||||
SKY(15), BLOCK(0);
|
||||
|
||||
public final int defValue;
|
||||
|
||||
private LightType(int def) {
|
||||
this.defValue = def;
|
||||
}
|
||||
}
|
|
@ -134,10 +134,7 @@ public abstract class World implements IWorldAccess {
|
|||
}
|
||||
|
||||
public Biome getBiomeGenForCoords(final BlockPos pos) {
|
||||
if(this.isBlockLoaded(pos))
|
||||
return this.getChunk(pos).getBiome(pos, null);
|
||||
else
|
||||
return Biome.DEF_BIOME;
|
||||
return Biome.DEF_BIOME;
|
||||
}
|
||||
|
||||
public boolean isAirBlock(BlockPos pos) {
|
||||
|
@ -192,7 +189,7 @@ public abstract class World implements IWorldAccess {
|
|||
}
|
||||
|
||||
protected boolean isLoaded(int x, int z, boolean allowEmpty) {
|
||||
return allowEmpty || !this.getChunk(x, z).isEmpty();
|
||||
return allowEmpty || !this.getChunk(x, z).isDummy();
|
||||
}
|
||||
|
||||
public Chunk getChunk(BlockPos pos) {
|
||||
|
@ -282,13 +279,7 @@ public abstract class World implements IWorldAccess {
|
|||
z2 = x2;
|
||||
x2 = i;
|
||||
}
|
||||
|
||||
if(!this.dimension.hasNoLight()) {
|
||||
for(int j = x2; j <= z2; ++j) {
|
||||
this.checkLightFor(LightType.SKY, new BlockPos(x1, j, z1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.markBlockRangeForRenderUpdate(x1, x2, z1, x1, z2, z1);
|
||||
}
|
||||
|
||||
|
@ -338,11 +329,7 @@ public abstract class World implements IWorldAccess {
|
|||
iblockstate.getBlock().onNeighborBlockChange(this, pos, iblockstate, blockIn);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canSeeSky(BlockPos pos) {
|
||||
return this.getChunk(pos).canSeeSky(pos);
|
||||
}
|
||||
|
||||
|
||||
public int getLight(BlockPos pos) {
|
||||
if(pos.getY() < 0) {
|
||||
return 0;
|
||||
|
@ -403,123 +390,84 @@ public abstract class World implements IWorldAccess {
|
|||
return 15;
|
||||
}
|
||||
}
|
||||
|
||||
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(LightType type, BlockPos pos) {
|
||||
if(this.dimension.hasNoLight() && type == LightType.SKY) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
if(pos.getY() < 0) {
|
||||
pos = new BlockPos(pos.getX(), 0, pos.getZ());
|
||||
}
|
||||
|
||||
if(!isValid(pos)) {
|
||||
return type.defValue;
|
||||
}
|
||||
else if(!this.isBlockLoaded(pos)) {
|
||||
return type.defValue;
|
||||
}
|
||||
else if(this.getState(pos).getBlock().getSumBrightness()) {
|
||||
int i1 = this.getLightFor(type, pos.up());
|
||||
int i = this.getLightFor(type, pos.east());
|
||||
int j = this.getLightFor(type, pos.west());
|
||||
int k = this.getLightFor(type, pos.south());
|
||||
int l = this.getLightFor(type, pos.north());
|
||||
|
||||
if(i > i1) {
|
||||
i1 = i;
|
||||
}
|
||||
|
||||
if(j > i1) {
|
||||
i1 = j;
|
||||
}
|
||||
|
||||
if(k > i1) {
|
||||
i1 = k;
|
||||
}
|
||||
|
||||
if(l > i1) {
|
||||
i1 = l;
|
||||
}
|
||||
|
||||
return i1;
|
||||
}
|
||||
else {
|
||||
Chunk chunk = this.getChunk(pos);
|
||||
return chunk.getLight(type, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getLightFor(LightType type, BlockPos pos) {
|
||||
|
||||
public int getLightFromNeighborsFor(BlockPos pos) {
|
||||
if(pos.getY() < 0) {
|
||||
pos = new BlockPos(pos.getX(), 0, pos.getZ());
|
||||
}
|
||||
|
||||
if(!isValid(pos)) {
|
||||
return type.defValue;
|
||||
return 0;
|
||||
}
|
||||
else if(!this.isBlockLoaded(pos)) {
|
||||
return type.defValue;
|
||||
return 0;
|
||||
}
|
||||
else if(this.getState(pos).getBlock().getSumBrightness()) {
|
||||
int i1 = this.getLightFor(pos.up());
|
||||
int i = this.getLightFor(pos.east());
|
||||
int j = this.getLightFor(pos.west());
|
||||
int k = this.getLightFor(pos.south());
|
||||
int l = this.getLightFor(pos.north());
|
||||
|
||||
if(i > i1) {
|
||||
i1 = i;
|
||||
}
|
||||
|
||||
if(j > i1) {
|
||||
i1 = j;
|
||||
}
|
||||
|
||||
if(k > i1) {
|
||||
i1 = k;
|
||||
}
|
||||
|
||||
if(l > i1) {
|
||||
i1 = l;
|
||||
}
|
||||
|
||||
return i1;
|
||||
}
|
||||
else {
|
||||
Chunk chunk = this.getChunk(pos);
|
||||
return chunk.getLight(type, pos);
|
||||
return chunk.getLight(pos);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLightFor(LightType type, BlockPos pos, int lightValue) {
|
||||
public int getLightFor(BlockPos pos) {
|
||||
if(pos.getY() < 0) {
|
||||
pos = new BlockPos(pos.getX(), 0, pos.getZ());
|
||||
}
|
||||
|
||||
if(!isValid(pos)) {
|
||||
return 0;
|
||||
}
|
||||
else if(!this.isBlockLoaded(pos)) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
Chunk chunk = this.getChunk(pos);
|
||||
return chunk.getLight(pos);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLightFor(BlockPos pos, int lightValue) {
|
||||
if(isValid(pos)) {
|
||||
if(this.isBlockLoaded(pos)) {
|
||||
Chunk chunk = this.getChunk(pos);
|
||||
chunk.setLight(type, pos, lightValue);
|
||||
chunk.setLight(pos, lightValue);
|
||||
this.notifyLightSet(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getCombinedLight(BlockPos pos, int lightValue) {
|
||||
int i = this.getLightFromNeighborsFor(LightType.SKY, pos);
|
||||
int j = this.getLightFromNeighborsFor(LightType.BLOCK, pos);
|
||||
int j = this.getLightFromNeighborsFor(pos);
|
||||
|
||||
if(j < lightValue) {
|
||||
j = lightValue;
|
||||
}
|
||||
|
||||
return i << 20 | j << 4;
|
||||
return 15 << 20 | j << 4;
|
||||
}
|
||||
|
||||
public float getLightBrightness(BlockPos pos) {
|
||||
|
@ -935,8 +883,32 @@ public abstract class World implements IWorldAccess {
|
|||
return f * (float)Math.PI * 2.0F;
|
||||
}
|
||||
|
||||
public BlockPos getPrecipitationHeight(BlockPos pos) {
|
||||
return this.getChunk(pos).getPrecipitation(pos);
|
||||
public BlockPos getPrecipitationHeight(BlockPos pos, int y, int scan) {
|
||||
scan = y - scan;
|
||||
int x = pos.getX();
|
||||
int z = pos.getZ();
|
||||
BlockPos loc = new BlockPos(x, y, z);
|
||||
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(x, y, z);
|
||||
}
|
||||
|
||||
public BlockPos getHeight(BlockPos pos) {
|
||||
return this.getPrecipitationHeight(pos, 256, 256);
|
||||
}
|
||||
|
||||
public void updateEntities() {
|
||||
|
@ -1519,12 +1491,15 @@ public abstract class World implements IWorldAccess {
|
|||
for(int i = 0; i < this.players.size(); ++i) {
|
||||
EntityNPC entityplayer = (EntityNPC)this.players.get(i);
|
||||
int j = ExtMath.floord(entityplayer.posX / 16.0D);
|
||||
int n = ExtMath.floord(entityplayer.posY / 16.0D);
|
||||
int k = ExtMath.floord(entityplayer.posZ / 16.0D);
|
||||
// int l = this.getRenderDistanceChunks();
|
||||
|
||||
for(int i1 = -l; i1 <= l; ++i1) {
|
||||
for(int j1 = -l; j1 <= l; ++j1) {
|
||||
this.active.add(new ChunkPos(i1 + j, j1 + k));
|
||||
for(int n1 = -l; n1 <= l; ++n1) {
|
||||
for(int j1 = -l; j1 <= l; ++j1) {
|
||||
this.active.add(new ChunkPos(i1 + j, n1 + n, j1 + k));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1593,7 +1568,7 @@ public abstract class World implements IWorldAccess {
|
|||
return true;
|
||||
}
|
||||
else {
|
||||
if(pos.getY() >= 0 && pos.getY() < 512 && this.getLightFor(LightType.BLOCK, pos) < 10) {
|
||||
if(pos.getY() >= 0 && pos.getY() < 512 && this.getLightFor(pos) < 10) {
|
||||
Block block = this.getState(pos).getBlock();
|
||||
|
||||
if((block.getMaterial() == Material.air || (allowLayers && block == Blocks.snow_layer))
|
||||
|
@ -1607,59 +1582,47 @@ public abstract class World implements IWorldAccess {
|
|||
}
|
||||
|
||||
public boolean checkLight(BlockPos pos) {
|
||||
boolean flag = false;
|
||||
|
||||
if(!this.dimension.hasNoLight()) {
|
||||
flag |= this.checkLightFor(LightType.SKY, pos);
|
||||
}
|
||||
|
||||
flag = flag | this.checkLightFor(LightType.BLOCK, pos);
|
||||
return flag;
|
||||
return this.checkLightFor(pos);
|
||||
}
|
||||
|
||||
private int getRawLight(BlockPos pos, LightType lightType) {
|
||||
if(lightType == LightType.SKY && this.canSeeSky(pos)) {
|
||||
return 15;
|
||||
private int getRawLight(BlockPos pos) {
|
||||
Block block = this.getState(pos).getBlock();
|
||||
int i = block.getLightValue();
|
||||
int j = block.getLightOpacity();
|
||||
|
||||
if(j >= 15 && block.getLightValue() > 0) {
|
||||
j = 1;
|
||||
}
|
||||
|
||||
if(j < 1) {
|
||||
j = 1;
|
||||
}
|
||||
|
||||
if(j >= 15) {
|
||||
return 0;
|
||||
}
|
||||
else if(i >= 14) {
|
||||
return i;
|
||||
}
|
||||
else {
|
||||
Block block = this.getState(pos).getBlock();
|
||||
int i = lightType == LightType.SKY ? 0 : block.getLightValue();
|
||||
int j = block.getLightOpacity();
|
||||
for(Facing enumfacing : Facing.values()) {
|
||||
BlockPos blockpos = pos.offset(enumfacing);
|
||||
int k = this.getLightFor(blockpos) - j;
|
||||
|
||||
if(j >= 15 && block.getLightValue() > 0) {
|
||||
j = 1;
|
||||
}
|
||||
|
||||
if(j < 1) {
|
||||
j = 1;
|
||||
}
|
||||
|
||||
if(j >= 15) {
|
||||
return 0;
|
||||
}
|
||||
else if(i >= 14) {
|
||||
return i;
|
||||
}
|
||||
else {
|
||||
for(Facing enumfacing : Facing.values()) {
|
||||
BlockPos blockpos = pos.offset(enumfacing);
|
||||
int k = this.getLightFor(lightType, blockpos) - j;
|
||||
|
||||
if(k > i) {
|
||||
i = k;
|
||||
}
|
||||
|
||||
if(i >= 14) {
|
||||
return i;
|
||||
}
|
||||
if(k > i) {
|
||||
i = k;
|
||||
}
|
||||
|
||||
return i;
|
||||
if(i >= 14) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkLightFor(LightType lightType, BlockPos pos) {
|
||||
public boolean checkLightFor(BlockPos pos) {
|
||||
if(!this.isAreaLoaded(pos, 17, false)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1667,8 +1630,8 @@ public abstract class World implements IWorldAccess {
|
|||
int i = 0;
|
||||
int j = 0;
|
||||
// this.profiler.start("getBrightness");
|
||||
int k = this.getLightFor(lightType, pos);
|
||||
int l = this.getRawLight(pos, lightType);
|
||||
int k = this.getLightFor(pos);
|
||||
int l = this.getRawLight(pos);
|
||||
int i1 = pos.getX();
|
||||
int j1 = pos.getY();
|
||||
int k1 = pos.getZ();
|
||||
|
@ -1686,10 +1649,10 @@ public abstract class World implements IWorldAccess {
|
|||
int k2 = (l1 >> 12 & 63) - 32 + k1;
|
||||
int l2 = l1 >> 18 & 15;
|
||||
BlockPos blockpos = new BlockPos(i2, j2, k2);
|
||||
int i3 = this.getLightFor(lightType, blockpos);
|
||||
int i3 = this.getLightFor(blockpos);
|
||||
|
||||
if(i3 == l2) {
|
||||
this.setLightFor(lightType, blockpos, 0);
|
||||
this.setLightFor(blockpos, 0);
|
||||
|
||||
if(l2 > 0) {
|
||||
int j3 = ExtMath.absi(i2 - i1);
|
||||
|
@ -1705,7 +1668,7 @@ public abstract class World implements IWorldAccess {
|
|||
int k4 = k2 + enumfacing.getFrontOffsetZ();
|
||||
blockpos$mutableblockpos.set(i4, j4, k4);
|
||||
int l4 = Math.max(1, this.getState(blockpos$mutableblockpos).getBlock().getLightOpacity());
|
||||
i3 = this.getLightFor(lightType, blockpos$mutableblockpos);
|
||||
i3 = this.getLightFor(blockpos$mutableblockpos);
|
||||
|
||||
if(i3 == l2 - l4 && j < this.lightUpdate.length) {
|
||||
this.lightUpdate[j++] = i4 - i1 + 32 | j4 - j1 + 32 << 6 | k4 - k1 + 32 << 12 | l2 - l4 << 18;
|
||||
|
@ -1728,11 +1691,11 @@ public abstract class World implements IWorldAccess {
|
|||
int k5 = (i5 >> 6 & 63) - 32 + j1;
|
||||
int l5 = (i5 >> 12 & 63) - 32 + k1;
|
||||
BlockPos blockpos1 = new BlockPos(j5, k5, l5);
|
||||
int i6 = this.getLightFor(lightType, blockpos1);
|
||||
int j6 = this.getRawLight(blockpos1, lightType);
|
||||
int i6 = this.getLightFor(blockpos1);
|
||||
int j6 = this.getRawLight(blockpos1);
|
||||
|
||||
if(j6 != i6) {
|
||||
this.setLightFor(lightType, blockpos1, j6);
|
||||
this.setLightFor(blockpos1, j6);
|
||||
|
||||
if(j6 > i6) {
|
||||
int k6 = Math.abs(j5 - i1);
|
||||
|
@ -1741,27 +1704,27 @@ public abstract class World implements IWorldAccess {
|
|||
boolean flag = j < this.lightUpdate.length - 6;
|
||||
|
||||
if(k6 + l6 + i7 < 17 && flag) {
|
||||
if(this.getLightFor(lightType, blockpos1.west()) < j6) {
|
||||
if(this.getLightFor(blockpos1.west()) < j6) {
|
||||
this.lightUpdate[j++] = j5 - 1 - i1 + 32 + (k5 - j1 + 32 << 6) + (l5 - k1 + 32 << 12);
|
||||
}
|
||||
|
||||
if(this.getLightFor(lightType, blockpos1.east()) < j6) {
|
||||
if(this.getLightFor(blockpos1.east()) < j6) {
|
||||
this.lightUpdate[j++] = j5 + 1 - i1 + 32 + (k5 - j1 + 32 << 6) + (l5 - k1 + 32 << 12);
|
||||
}
|
||||
|
||||
if(this.getLightFor(lightType, blockpos1.down()) < j6) {
|
||||
if(this.getLightFor(blockpos1.down()) < j6) {
|
||||
this.lightUpdate[j++] = j5 - i1 + 32 + (k5 - 1 - j1 + 32 << 6) + (l5 - k1 + 32 << 12);
|
||||
}
|
||||
|
||||
if(this.getLightFor(lightType, blockpos1.up()) < j6) {
|
||||
if(this.getLightFor(blockpos1.up()) < j6) {
|
||||
this.lightUpdate[j++] = j5 - i1 + 32 + (k5 + 1 - j1 + 32 << 6) + (l5 - k1 + 32 << 12);
|
||||
}
|
||||
|
||||
if(this.getLightFor(lightType, blockpos1.north()) < j6) {
|
||||
if(this.getLightFor(blockpos1.north()) < j6) {
|
||||
this.lightUpdate[j++] = j5 - i1 + 32 + (k5 - j1 + 32 << 6) + (l5 - 1 - k1 + 32 << 12);
|
||||
}
|
||||
|
||||
if(this.getLightFor(lightType, blockpos1.south()) < j6) {
|
||||
if(this.getLightFor(blockpos1.south()) < j6) {
|
||||
this.lightUpdate[j++] = j5 - i1 + 32 + (k5 - j1 + 32 << 6) + (l5 + 1 - k1 + 32 << 12);
|
||||
}
|
||||
}
|
||||
|
@ -2064,10 +2027,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.getHeight(strikePosition).getY() > strikePosition.getY()) {
|
||||
return false;
|
||||
}
|
||||
return !this.canSnowAt(strikePosition, false, false);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -66,12 +66,13 @@ public class Region {
|
|||
private static volatile boolean waiting;
|
||||
private static volatile boolean killed;
|
||||
|
||||
private final int[] timestamps = new int[64];
|
||||
private final int[] positions = new int[64];
|
||||
private final int[] sizes = new int[64];
|
||||
private final int[] timestamps = new int[512];
|
||||
private final int[] positions = new int[512];
|
||||
private final int[] sizes = new int[512];
|
||||
private final File regFile;
|
||||
private final File folder;
|
||||
private final int xPos;
|
||||
private final int yPos;
|
||||
private final int zPos;
|
||||
|
||||
private RandomAccessFile file;
|
||||
|
@ -79,26 +80,27 @@ public class Region {
|
|||
private int offset;
|
||||
private boolean modified;
|
||||
|
||||
public Region(File dir, int x, int z) {
|
||||
File sdir = new File(dir, Util.getRegionFolder(x << 3, z << 3));
|
||||
public Region(File dir, int x, int y, int z) {
|
||||
File sdir = new File(dir, Util.getRegionFolder(x << 3, y << 3, z << 3));
|
||||
if(!sdir.exists())
|
||||
sdir.mkdirs();
|
||||
this.regFile = new File(sdir, Util.getRegionName(x << 3, z << 3));
|
||||
this.regFile = new File(sdir, Util.getRegionName(x << 3, y << 3, z << 3));
|
||||
this.folder = dir;
|
||||
this.xPos = x;
|
||||
this.yPos = y;
|
||||
this.zPos = z;
|
||||
try {
|
||||
if(this.regFile.exists())
|
||||
this.lastModified = this.regFile.lastModified();
|
||||
this.file = new RandomAccessFile(this.regFile, "rw");
|
||||
this.file.seek(0L);
|
||||
if(this.file.length() < 512L) {
|
||||
for(int i = 0; i < 64; i++) {
|
||||
if(this.file.length() < 4096L) {
|
||||
for(int i = 0; i < 512; i++) {
|
||||
this.file.writeLong(0L);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(int i = 0; i < 64; i++) {
|
||||
for(int i = 0; i < 512; i++) {
|
||||
int end = this.positions[i] = this.file.readUnsignedShort();
|
||||
end += ((this.sizes[i] = this.file.readUnsignedShort()) + 255) >> 8;
|
||||
this.timestamps[i] = this.file.readInt();
|
||||
|
@ -117,7 +119,7 @@ public class Region {
|
|||
File tmp = new File(this.folder, this.regFile.getName() + ".tmp");
|
||||
RandomAccessFile file = new RandomAccessFile(tmp, "rw");
|
||||
int offset = 0;
|
||||
for(int i = 0; i < 64; i++) {
|
||||
for(int i = 0; i < 512; i++) {
|
||||
file.writeShort(this.sizes[i] == 0 ? 0 : offset);
|
||||
file.writeShort(this.sizes[i]);
|
||||
file.writeInt(this.timestamps[i]);
|
||||
|
@ -125,18 +127,18 @@ public class Region {
|
|||
}
|
||||
this.offset = offset;
|
||||
offset = 0;
|
||||
for(int i = 0; i < 64; i++) {
|
||||
for(int i = 0; i < 512; i++) {
|
||||
int size = this.sizes[i];
|
||||
if(size == 0) {
|
||||
this.positions[i] = 0;
|
||||
continue;
|
||||
}
|
||||
this.file.seek(512L + (long)(this.positions[i] << 8));
|
||||
this.file.seek(4096L + (long)(this.positions[i] << 8));
|
||||
this.file.read(buffer, 0, size);
|
||||
file.write(buffer, 0, size);
|
||||
this.positions[i] = offset;
|
||||
offset += (size + 255) >> 8;
|
||||
file.seek(512L + (long)(offset << 8));
|
||||
file.seek(4096L + (long)(offset << 8));
|
||||
}
|
||||
file.close();
|
||||
this.file.close();
|
||||
|
@ -145,7 +147,7 @@ public class Region {
|
|||
this.modified = false;
|
||||
}
|
||||
|
||||
private synchronized byte[] read(int x, int z) {
|
||||
private synchronized byte[] read(int x, int y, int z) {
|
||||
if(this.timestamps[x + z * 8] == 0)
|
||||
return null;
|
||||
FileInputStream in = null;
|
||||
|
@ -153,12 +155,12 @@ public class Region {
|
|||
// this.file.seek((long)(512 + (x + z * 8) * 8192));
|
||||
int size = this.sizes[x + z * 8]; // this.file.readShort();
|
||||
if(size > 8192 /* - 2 */ || size < 0) {
|
||||
Log.JNI.warn("Chunk-Region-Datei " + this.regFile + " hat eine ungültige Größe bei " + x + ", " + z + ", überspringe");
|
||||
Log.JNI.warn("Chunk-Region-Datei " + this.regFile + " hat eine ungültige Größe bei " + x + ", " + y + ", " + z + ", überspringe");
|
||||
return null;
|
||||
}
|
||||
byte[] data;
|
||||
if(size == 0) {
|
||||
File expand = getExpansionFile(this.folder, this.xPos * 8 + x, this.zPos * 8 + z);
|
||||
File expand = getExpansionFile(this.folder, this.xPos * 8 + x, this.yPos * 8 + y, this.zPos * 8 + z);
|
||||
if(!expand.exists()) {
|
||||
Log.JNI.warn("Chunk-Erweiterungs-Datei " + expand + " ist nicht vorhanden oder nicht lesbar, überspringe");
|
||||
return null;
|
||||
|
@ -182,11 +184,11 @@ public class Region {
|
|||
}
|
||||
else {
|
||||
int pos = this.positions[x + z * 8] << 8;
|
||||
if(pos + size > this.file.length() - 512L || pos < 0) {
|
||||
Log.JNI.warn("Chunk-Region-Datei " + this.regFile + " hat eine ungültige Position bei " + x + ", " + z + ", überspringe");
|
||||
if(pos + size > this.file.length() - 4096L || pos < 0) {
|
||||
Log.JNI.warn("Chunk-Region-Datei " + this.regFile + " hat eine ungültige Position bei " + x + ", " + y + ", " + z + ", überspringe");
|
||||
return null;
|
||||
}
|
||||
this.file.seek(512L + (long)pos);
|
||||
this.file.seek(4096L + (long)pos);
|
||||
data = new byte[size]; // - 2];
|
||||
this.file.read(data);
|
||||
}
|
||||
|
@ -200,14 +202,14 @@ public class Region {
|
|||
}
|
||||
catch(IOException e1) {
|
||||
}
|
||||
Log.JNI.error(e, "Fehler beim lesen von Chunk-Region-Datei " + this.regFile + " bei " + x + ", " + z + ", überspringe");
|
||||
Log.JNI.error(e, "Fehler beim lesen von Chunk-Region-Datei " + this.regFile + " bei " + x + ", " + y + ", " + z + ", überspringe");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void write(int x, int z, byte[] data, int size) {
|
||||
private synchronized void write(int x, int y, int z, byte[] data, int size) {
|
||||
try {
|
||||
if(((int)this.file.length() - 512) >= 1048576)
|
||||
if(((int)this.file.length() - 4096) >= 1048576)
|
||||
this.reorganize(true);
|
||||
this.modified = true;
|
||||
// if(size >= 8192)
|
||||
|
@ -216,7 +218,7 @@ public class Region {
|
|||
if(size /* + 2 */ > 8192) {
|
||||
FileOutputStream out = null;
|
||||
try {
|
||||
out = new FileOutputStream(getExpansionFile(this.folder, this.xPos * 8 + x, this.zPos * 8 + z));
|
||||
out = new FileOutputStream(getExpansionFile(this.folder, this.xPos * 8 + x, this.yPos * 8 + y, this.zPos * 8 + z));
|
||||
int remain = size;
|
||||
while(remain > 0) {
|
||||
int n = Math.min(remain, 8192);
|
||||
|
@ -240,7 +242,7 @@ public class Region {
|
|||
else {
|
||||
pos = this.offset;
|
||||
this.offset += (size + 255) >> 8;
|
||||
this.file.seek(512L + (long)(pos << 8)); // (512 + (x + z * 8) * 8192));
|
||||
this.file.seek(4096L + (long)(pos << 8)); // (512 + (x + z * 8) * 8192));
|
||||
// this.file.writeShort(size);
|
||||
this.file.write(data, 0, size);
|
||||
}
|
||||
|
@ -268,38 +270,38 @@ public class Region {
|
|||
}
|
||||
}
|
||||
|
||||
public long getTimestamp(int x, int z) {
|
||||
public long getTimestamp(int x, int y, int z) {
|
||||
return (long)this.timestamps[x + z * 8] * 10000L;
|
||||
}
|
||||
|
||||
public void writeTag(int x, int z, NBTTagCompound tag) throws IOException {
|
||||
public void writeTag(int x, int y, int z, NBTTagCompound tag) throws IOException {
|
||||
ChunkBuffer buf = new ChunkBuffer();
|
||||
DataOutputStream out = new DataOutputStream(new DeflaterOutputStream(buf));
|
||||
NBTLoader.write(tag, out);
|
||||
out.close();
|
||||
this.write(x, z, buf.getData(), buf.size());
|
||||
this.write(x, y, z, buf.getData(), buf.size());
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return this.regFile;
|
||||
}
|
||||
|
||||
private static synchronized Region getRegionFile(File dir, int x, int z) {
|
||||
Region reg = CACHE.get(dir + "." + x + "." + z);
|
||||
private static synchronized Region getRegionFile(File dir, int x, int y, int z) {
|
||||
Region reg = CACHE.get(dir + "." + x + "." + y + "." + z);
|
||||
if(reg != null)
|
||||
return reg;
|
||||
if(CACHE.size() >= 256)
|
||||
clearCache(false);
|
||||
Region nreg = new Region(dir, x, z);
|
||||
CACHE.put(dir + "." + x + "." + z, nreg);
|
||||
Region nreg = new Region(dir, x, y, z);
|
||||
CACHE.put(dir + "." + x + "." + y + "." + z, nreg);
|
||||
return nreg;
|
||||
}
|
||||
|
||||
private static File getExpansionFile(File dir, int x, int z) {
|
||||
File sdir = new File(dir, Util.getRegionFolder(x, z));
|
||||
private static File getExpansionFile(File dir, int x, int y, int z) {
|
||||
File sdir = new File(dir, Util.getRegionFolder(x, y, z));
|
||||
if(!sdir.exists())
|
||||
sdir.mkdirs();
|
||||
return new File(sdir, String.format("c.%c%X%c%X.chk", x < 0 ? 'n' : 'p', (x < 0) ? -x : x, z < 0 ? 'n' : 'p', (z < 0) ? -z : z));
|
||||
return new File(sdir, String.format("c.%c%X%c%X%c%X.chk", x < 0 ? 'n' : 'p', (x < 0) ? -x : x, y < 0 ? 'n' : 'p', (y < 0) ? -y : y, z < 0 ? 'n' : 'p', (z < 0) ? -z : z));
|
||||
}
|
||||
|
||||
private static synchronized void clearCache(boolean all) {
|
||||
|
@ -342,52 +344,33 @@ public class Region {
|
|||
clearCache(true);
|
||||
}
|
||||
|
||||
public static /* synchronized */ NBTTagCompound readChunk(File dir, int x, int z) throws IOException {
|
||||
// return getRegionFile(dir, x >> 3, z >> 3).readTag(x & 7, z & 7);
|
||||
byte[] data = getRegionFile(dir, x >> 3, z >> 3).read(x & 7, z & 7);
|
||||
public static /* synchronized */ NBTTagCompound readChunk(File dir, int x, int y, int z) throws IOException {
|
||||
byte[] data = getRegionFile(dir, x >> 3, y >> 3, z >> 3).read(x & 7, y & 7, z & 7);
|
||||
if(data == null)
|
||||
return null;
|
||||
return NBTLoader.read(new DataInputStream(new BufferedInputStream(new InflaterInputStream(new ByteArrayInputStream(data)))));
|
||||
}
|
||||
|
||||
public static /* synchronized */ void writeChunk(File dir, int x, int z, NBTTagCompound tag) throws IOException {
|
||||
public static /* synchronized */ void writeChunk(File dir, int x, int y, int z, NBTTagCompound tag) throws IOException {
|
||||
ChunkBuffer buf = new ChunkBuffer();
|
||||
DataOutputStream out = new DataOutputStream(new DeflaterOutputStream(buf));
|
||||
NBTLoader.write(tag, out);
|
||||
out.close();
|
||||
getRegionFile(dir, x >> 3, z >> 3).write(x & 7, z & 7, buf.getData(), buf.size());
|
||||
// getRegionFile(dir, x >> 3, z >> 3).writeTag(x & 7, z & 7, tag);
|
||||
getRegionFile(dir, x >> 3, y >> 3, z >> 3).write(x & 7, y & 7, z & 7, buf.getData(), buf.size());
|
||||
}
|
||||
|
||||
public static Chunk readNbt(WorldServer world, int x, int z, NBTTagCompound tag) {
|
||||
// if(!tag.hasKey("Level", 10)) {
|
||||
// Log.error("Chunk-Datei bei " + x + "," + z + " hat keine Level-Daten, überspringe");
|
||||
// return null;
|
||||
// }
|
||||
// tag = tag.getCompoundTag("Level");
|
||||
if(!tag.hasKey("Sections", 9)) {
|
||||
Log.JNI.warn("Chunk-Datei bei " + x + "," + z + " hat keine Block-Daten, überspringe");
|
||||
return null;
|
||||
}
|
||||
Chunk chunk = new Chunk(world, x, z);
|
||||
chunk.setHeights(tag.getIntArray("HeightMap"));
|
||||
public static Chunk readNbt(WorldServer world, int x, int y, int z, NBTTagCompound tag) {
|
||||
Chunk chunk = new Chunk(world, x, y, z);
|
||||
chunk.setTerrainPopulated(tag.getBoolean("TerrainPopulated"));
|
||||
chunk.setLightPopulated(tag.getBoolean("LightPopulated"));
|
||||
chunk.setInhabited(tag.getLong("InhabitedTime"));
|
||||
NBTTagList sects = tag.getTagList("Sections", 10);
|
||||
int stor = 32;
|
||||
BlockArray[] sections = new BlockArray[stor];
|
||||
boolean light = !world.dimension.hasNoLight();
|
||||
|
||||
for(int n = 0; n < sects.tagCount(); ++n) {
|
||||
NBTTagCompound sect = sects.getCompoundTagAt(n);
|
||||
int y = sect.getByte("Y");
|
||||
BlockArray storage = new BlockArray(y << 4, light);
|
||||
byte[] blocks = sect.getByteArray("Blocks");
|
||||
NibbleArray data = new NibbleArray(sect.getByteArray("Data"));
|
||||
NibbleArray adddata = sect.hasKey("Add", 7) ? new NibbleArray(sect.getByteArray("Add")) : null;
|
||||
if(tag.hasKey("Blocks", 7)) {
|
||||
BlockArray storage = new BlockArray();
|
||||
byte[] blocks = tag.getByteArray("Blocks");
|
||||
NibbleArray data = new NibbleArray(tag.getByteArray("Data"));
|
||||
NibbleArray adddata = tag.hasKey("Add", 7) ? new NibbleArray(tag.getByteArray("Add")) : null;
|
||||
char[] seg = new char[blocks.length];
|
||||
|
||||
|
||||
for(int c = 0; c < seg.length; ++c) {
|
||||
int cx = c & 15;
|
||||
int cy = c >> 8 & 15;
|
||||
|
@ -395,22 +378,13 @@ public class Region {
|
|||
int ca = adddata != null ? adddata.get(cx, cy, cz) : 0;
|
||||
seg[c] = (char)(ca << 12 | (blocks[c] & 255) << 4 | data.get(cx, cy, cz));
|
||||
}
|
||||
|
||||
|
||||
storage.setData(seg);
|
||||
storage.setBlocklight(new NibbleArray(sect.getByteArray("BlockLight")));
|
||||
|
||||
if(light) {
|
||||
storage.setSkylight(new NibbleArray(sect.getByteArray("SkyLight")));
|
||||
}
|
||||
|
||||
storage.setBlocklight(new NibbleArray(tag.getByteArray("BlockLight")));
|
||||
|
||||
storage.update();
|
||||
sections[y] = storage;
|
||||
}
|
||||
|
||||
chunk.setStorage(sections);
|
||||
|
||||
if(tag.hasKey("Biomes", 7)) {
|
||||
chunk.setBiomes(tag.getByteArray("Biomes"));
|
||||
|
||||
chunk.setStorage(storage);
|
||||
}
|
||||
|
||||
NBTTagList entities = tag.getTagList("Entities", 10);
|
||||
|
@ -490,73 +464,52 @@ 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.setBoolean("LightPopulated", chunk.isLightPopulated());
|
||||
tag.setLong("InhabitedTime", chunk.getInhabited());
|
||||
BlockArray[] sections = chunk.getStorage();
|
||||
NBTTagList sects = new NBTTagList();
|
||||
boolean light = !world.dimension.hasNoLight();
|
||||
|
||||
for(BlockArray storage : sections) {
|
||||
if(storage != null) {
|
||||
NBTTagCompound sect = new NBTTagCompound();
|
||||
sect.setByte("Y", (byte)(storage.getY() >> 4 & 511));
|
||||
byte[] blocks = new byte[storage.getData().length];
|
||||
NibbleArray data = new NibbleArray();
|
||||
NibbleArray adddata = null;
|
||||
BlockArray storage = chunk.getStorage();
|
||||
if(storage != null) {
|
||||
byte[] blocks = new byte[storage.getData().length];
|
||||
NibbleArray data = new NibbleArray();
|
||||
NibbleArray adddata = null;
|
||||
|
||||
for(int c = 0; c < storage.getData().length; ++c) {
|
||||
char cd = storage.getData()[c];
|
||||
int cx = c & 15;
|
||||
int cy = c >> 8 & 15;
|
||||
int cz = c >> 4 & 15;
|
||||
for(int c = 0; c < storage.getData().length; ++c) {
|
||||
char cd = storage.getData()[c];
|
||||
int cx = c & 15;
|
||||
int cy = c >> 8 & 15;
|
||||
int cz = c >> 4 & 15;
|
||||
|
||||
if(cd >> 12 != 0) {
|
||||
if(adddata == null) {
|
||||
adddata = new NibbleArray();
|
||||
}
|
||||
|
||||
adddata.set(cx, cy, cz, cd >> 12);
|
||||
if(cd >> 12 != 0) {
|
||||
if(adddata == null) {
|
||||
adddata = new NibbleArray();
|
||||
}
|
||||
|
||||
blocks[c] = (byte)(cd >> 4 & 255);
|
||||
data.set(cx, cy, cz, cd & 15);
|
||||
adddata.set(cx, cy, cz, cd >> 12);
|
||||
}
|
||||
|
||||
sect.setByteArray("Blocks", blocks);
|
||||
sect.setByteArray("Data", data.getData());
|
||||
|
||||
if(adddata != null) {
|
||||
sect.setByteArray("Add", adddata.getData());
|
||||
}
|
||||
|
||||
sect.setByteArray("BlockLight", storage.getBlocklight().getData());
|
||||
|
||||
if(light) {
|
||||
sect.setByteArray("SkyLight", storage.getSkylight().getData());
|
||||
}
|
||||
else {
|
||||
sect.setByteArray("SkyLight", new byte[storage.getBlocklight().getData().length]);
|
||||
}
|
||||
|
||||
sects.appendTag(sect);
|
||||
blocks[c] = (byte)(cd >> 4 & 255);
|
||||
data.set(cx, cy, cz, cd & 15);
|
||||
}
|
||||
|
||||
tag.setByteArray("Blocks", blocks);
|
||||
tag.setByteArray("Data", data.getData());
|
||||
|
||||
if(adddata != null) {
|
||||
tag.setByteArray("Add", adddata.getData());
|
||||
}
|
||||
|
||||
tag.setByteArray("BlockLight", storage.getBlocklight().getData());
|
||||
}
|
||||
|
||||
tag.setTag("Sections", sects);
|
||||
tag.setByteArray("Biomes", chunk.getBiomes());
|
||||
chunk.setHasEntities(false);
|
||||
NBTTagList entities = new NBTTagList();
|
||||
|
||||
for(int n = 0; n < chunk.getEntities().length; ++n) {
|
||||
for(Entity entity : chunk.getEntities()[n]) {
|
||||
NBTTagCompound ent = new NBTTagCompound();
|
||||
for(Entity entity : chunk.getEntities()) {
|
||||
NBTTagCompound ent = new NBTTagCompound();
|
||||
|
||||
if(entity.writeToNBTOptional(ent)) {
|
||||
chunk.setHasEntities(true);
|
||||
entities.appendTag(ent);
|
||||
}
|
||||
if(entity.writeToNBTOptional(ent)) {
|
||||
chunk.setHasEntities(true);
|
||||
entities.appendTag(ent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public abstract class Spawner {
|
|||
for(int cx = -range; cx <= range; ++cx) {
|
||||
for(int cz = -range; cz <= range; ++cz) {
|
||||
boolean flag = cx == -range || cx == range || cz == -range || cz == range;
|
||||
ChunkPos coord = new ChunkPos(cx + x, cz + z);
|
||||
ChunkPos coord = new ChunkPos(cx + x, 0, cz + z);
|
||||
if(!CHUNKS.contains(coord)) {
|
||||
++locs;
|
||||
if(!flag && coord.x << 4 >= -World.MAX_SIZE + 64 && coord.z << 4 >= -World.MAX_SIZE + 64
|
||||
|
@ -87,15 +87,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.getHeight(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();
|
||||
|
|
|
@ -76,7 +76,6 @@ import common.world.BlockArray;
|
|||
import common.world.Chunk;
|
||||
import common.world.Explosion;
|
||||
import common.world.AWorldServer;
|
||||
import common.world.LightType;
|
||||
import common.world.State;
|
||||
import common.world.Weather;
|
||||
import common.world.World;
|
||||
|
@ -162,13 +161,10 @@ public final class WorldServer extends AWorldServer {
|
|||
private BlockReplacer replacer;
|
||||
private FeatureDungeons dungeons;
|
||||
private State liquid;
|
||||
private State base;
|
||||
private State ceil;
|
||||
private FeatureOres[] ores;
|
||||
private FeatureLakes[] lakes;
|
||||
private FeatureLiquids[] liquids;
|
||||
private long seed;
|
||||
private int height;
|
||||
private int seaLevel;
|
||||
private boolean mobs;
|
||||
private boolean snow;
|
||||
|
@ -341,8 +337,6 @@ public final class WorldServer extends AWorldServer {
|
|||
this.caveGen = null;
|
||||
this.bigCaveGen = null;
|
||||
this.ravineGen = null;
|
||||
this.base = null;
|
||||
this.ceil = null;
|
||||
this.mobs = false;
|
||||
this.snow = false;
|
||||
this.strongholdGen = null;
|
||||
|
@ -422,8 +416,6 @@ public final class WorldServer extends AWorldServer {
|
|||
this.caveGen = this.createCaveGenerator();
|
||||
this.bigCaveGen = this.createBigCaveGenerator();
|
||||
this.ravineGen = this.createRavineGenerator();
|
||||
this.base = this.dimension.getWorldFloor();
|
||||
this.ceil = this.dimension.getWorldCeiling();
|
||||
this.mobs = this.dimension.hasMobs();
|
||||
this.snow = this.dimension.hasSnow();
|
||||
this.strongholdGen = this.dimension.hasStrongholds() ? new MapGenStronghold() : null;
|
||||
|
@ -437,7 +429,6 @@ public final class WorldServer extends AWorldServer {
|
|||
this.liquids = this.createLiquids();
|
||||
this.dungeons = this.createDungeonGenerator();
|
||||
}
|
||||
this.height = this.generator.getMaximumHeight();
|
||||
// this.teleporter = new Teleporter(this);
|
||||
this.calculateInitialSkylight();
|
||||
this.calculateInitialWeather();
|
||||
|
@ -624,10 +615,7 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
|
||||
public Biome getBiomeGenForCoords(final BlockPos pos) {
|
||||
if(this.isBlockLoaded(pos))
|
||||
return this.getChunk(pos).getBiome(pos, this.biomeGen);
|
||||
else
|
||||
return this.biomeGen.getBiomeGenerator(pos, Biome.DEF_BIOME);
|
||||
return this.biomeGen.getBiomeGenerator(pos, Biome.DEF_BIOME);
|
||||
}
|
||||
|
||||
public void setItemData(String dataID, WorldSavedData worldSavedDataIn) {
|
||||
|
@ -644,15 +632,13 @@ public final class WorldServer extends AWorldServer {
|
|||
|
||||
if(this.debug) {
|
||||
for(ChunkPos chunkcoordintpair1 : this.active) {
|
||||
this.getChunk(chunkcoordintpair1.x, chunkcoordintpair1.z).update(false);
|
||||
this.getChunk(chunkcoordintpair1.x, chunkcoordintpair1.z).update();
|
||||
}
|
||||
}
|
||||
else {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
||||
for(ChunkPos chunkcoordintpair : this.active) {
|
||||
int k = chunkcoordintpair.x * 16;
|
||||
int n = chunkcoordintpair.y * 16;
|
||||
int l = chunkcoordintpair.z * 16;
|
||||
// this.profiler.start("getChunk");
|
||||
Chunk chunk = this.getChunk(chunkcoordintpair.x, chunkcoordintpair.z);
|
||||
|
@ -661,7 +647,7 @@ public final class WorldServer extends AWorldServer {
|
|||
// this.profiler.next("checkLight");
|
||||
chunk.enqueueRelight();
|
||||
// this.profiler.next("tickChunk");
|
||||
chunk.update(false);
|
||||
chunk.update();
|
||||
// this.profiler.next("thunder");
|
||||
int l2 = Config.boltChance;
|
||||
|
||||
|
@ -679,10 +665,10 @@ public final class WorldServer extends AWorldServer {
|
|||
l2 = Config.weatherTick;
|
||||
|
||||
for(int z = 0; z < l2; z++) {
|
||||
if(this.rand.zrange(16) == 0) {
|
||||
if(this.rand.chance(16 * 32)) {
|
||||
this.updateLCG = this.updateLCG * 3 + 1013904223;
|
||||
int k2 = this.updateLCG >> 2;
|
||||
BlockPos blockpos2 = this.getPrecipitationHeight(new BlockPos(k + (k2 & 15), 0, l + (k2 >> 8 & 15)));
|
||||
BlockPos blockpos2 = this.getHeight(new BlockPos(k + (k2 & 15), 0, l + (k2 >> 8 & 15)));
|
||||
BlockPos blockpos1 = blockpos2.down();
|
||||
|
||||
if(this.canBlockFreeze(blockpos1, true)) {
|
||||
|
@ -711,24 +697,21 @@ public final class WorldServer extends AWorldServer {
|
|||
// this.profiler.next("tickBlocks");
|
||||
l2 = Config.randomTick;
|
||||
|
||||
if(l2 > 0) {
|
||||
for(BlockArray extendedblockstorage : chunk.getStorage()) {
|
||||
if(extendedblockstorage != null && extendedblockstorage.isTicked()) {
|
||||
for(int j1 = 0; j1 < l2; ++j1) {
|
||||
this.updateLCG = this.updateLCG * 3 + 1013904223;
|
||||
int k1 = this.updateLCG >> 2;
|
||||
int l1 = k1 & 15;
|
||||
int i2 = k1 >> 8 & 15;
|
||||
int j2 = k1 >> 16 & 15;
|
||||
++j;
|
||||
State iblockstate = extendedblockstorage.get(l1, j2, i2);
|
||||
Block block = iblockstate.getBlock();
|
||||
if(l2 > 0 && this.rand.chance(32)) {
|
||||
BlockArray extendedblockstorage = chunk.getStorage();
|
||||
if(extendedblockstorage != null && extendedblockstorage.isTicked()) {
|
||||
for(int j1 = 0; j1 < l2; ++j1) {
|
||||
this.updateLCG = this.updateLCG * 3 + 1013904223;
|
||||
int k1 = this.updateLCG >> 2;
|
||||
int l1 = k1 & 15;
|
||||
int i2 = k1 >> 8 & 15;
|
||||
int j2 = k1 >> 16 & 15;
|
||||
State iblockstate = extendedblockstorage.get(l1, j2, i2);
|
||||
Block block = iblockstate.getBlock();
|
||||
|
||||
if(block.getTickRandomly()) {
|
||||
++i;
|
||||
block.randomTick(this, new BlockPos(l1 + k, j2 + extendedblockstorage.getY(), i2 + l), iblockstate,
|
||||
this.rand);
|
||||
}
|
||||
if(block.getTickRandomly()) {
|
||||
block.randomTick(this, new BlockPos(l1 + k, j2 + n, i2 + l), iblockstate,
|
||||
this.rand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -740,12 +723,12 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
|
||||
private BlockPos adjustPosToNearbyEntity(BlockPos pos) {
|
||||
BlockPos blockpos = this.getPrecipitationHeight(pos);
|
||||
BlockPos blockpos = this.getHeight(pos);
|
||||
BoundingBox axisalignedbb = (new BoundingBox(blockpos, new BlockPos(blockpos.getX(), World.HEIGHT, blockpos.getZ()))).expand(3.0D,
|
||||
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;
|
||||
|
@ -1374,9 +1357,9 @@ public final class WorldServer extends AWorldServer {
|
|||
return chunk;
|
||||
}
|
||||
|
||||
private Chunk loadChunkFromFile(int x, int z) {
|
||||
private Chunk loadChunkFromFile(int x, int y, int z) {
|
||||
try {
|
||||
ChunkPos coord = new ChunkPos(x, z);
|
||||
ChunkPos coord = new ChunkPos(x, y, z);
|
||||
NBTTagCompound tag = this.toRemove.get(coord);
|
||||
if(tag == null) {
|
||||
tag = Region.readChunk(this.chunkDir, x, z);
|
||||
|
@ -1529,10 +1512,10 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
}
|
||||
|
||||
private void populate(int x, int z) {
|
||||
Chunk chunk = this.getChunk(x, z);
|
||||
private void populate(int x, int y, int z) {
|
||||
Chunk chunk = this.getChunk(x, y, z);
|
||||
if(!chunk.isTerrainPopulated()) {
|
||||
chunk.checkLight();
|
||||
chunk.setTerrainPopulated(true);
|
||||
BlockFalling.fallInstantly = true;
|
||||
int bx = x * 16;
|
||||
int bz = z * 16;
|
||||
|
@ -1543,7 +1526,7 @@ public final class WorldServer extends AWorldServer {
|
|||
long sz = this.grng.longv() / 2L * 2L + 1L;
|
||||
this.grng.setSeed((long)x * sx + (long)z * sz ^ this.seed);
|
||||
boolean lakes = true;
|
||||
ChunkPos coord = new ChunkPos(x, z);
|
||||
ChunkPos coord = new ChunkPos(x, y, z);
|
||||
if(this.bridgeGen != null) {
|
||||
this.bridgeGen.generateStructure(this, this.grng, coord);
|
||||
}
|
||||
|
@ -1587,7 +1570,7 @@ public final class WorldServer extends AWorldServer {
|
|||
pos = pos.add(8, 0, 8);
|
||||
for(int fx = 0; fx < 16; ++fx) {
|
||||
for(int fz = 0; fz < 16; ++fz) {
|
||||
BlockPos snow = this.getPrecipitationHeight(pos.add(fx, 0, fz));
|
||||
BlockPos snow = this.getHeight(pos.add(fx, 0, fz));
|
||||
BlockPos ice = snow.down();
|
||||
if(this.canBlockFreeze(ice, false)) {
|
||||
this.setState(ice, Blocks.ice.getState(), 2);
|
||||
|
@ -1603,9 +1586,9 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
}
|
||||
|
||||
private Chunk generate(int x, int z) {
|
||||
private Chunk generate(int x, int y, int z) {
|
||||
this.grng.setSeed((long)x * 341873128712L + (long)z * 132897987541L);
|
||||
ChunkPrimer primer = new ChunkPrimer(this.height);
|
||||
ChunkPrimer primer = new ChunkPrimer();
|
||||
this.generator.generateChunk(this, x, z, primer);
|
||||
this.biomeGen.getChunkBiomes(this.biomes, x * 16, z * 16, 16, 16);
|
||||
if(this.replacer != null) {
|
||||
|
@ -1635,7 +1618,7 @@ public final class WorldServer extends AWorldServer {
|
|||
if(this.scatteredGen != null) {
|
||||
this.scatteredGen.generate(this, x, z, primer);
|
||||
}
|
||||
return new Chunk(this, primer.getData(), primer.height, this.base, this.ceil, this.grng, this.biomes, x, z);
|
||||
return new Chunk(this, primer.getData(), x, y, z);
|
||||
}
|
||||
|
||||
public boolean isExterminated() {
|
||||
|
@ -1685,15 +1668,15 @@ public final class WorldServer extends AWorldServer {
|
|||
long pos = LongHashMap.packInt(chunk.xPos, chunk.zPos);
|
||||
chunk.onChunkUnload();
|
||||
this.chunks.remove(pos);
|
||||
chunk = this.generate(chunk.xPos, chunk.zPos);
|
||||
chunk = this.generate(chunk.xPos, chunk.yPos, chunk.zPos);
|
||||
this.chunks.add(pos, chunk);
|
||||
this.loaded.add(chunk);
|
||||
chunk.onChunkLoad();
|
||||
chunk.checkLight();
|
||||
chunk.setTerrainPopulated(true);
|
||||
chunk.setModified();
|
||||
}
|
||||
for(Chunk chunk : this.loaded) {
|
||||
chunk.update(false);
|
||||
chunk.update();
|
||||
}
|
||||
this.entities.removeAll(this.unloaded);
|
||||
for(int l = 0; l < this.unloaded.size(); ++l) {
|
||||
|
@ -1745,9 +1728,6 @@ public final class WorldServer extends AWorldServer {
|
|||
this.replacer = null;
|
||||
this.populate = false;
|
||||
this.liquid = Blocks.air.getState();
|
||||
this.base = Blocks.air.getState();
|
||||
this.ceil = null;
|
||||
this.height = this.generator.getMaximumHeight();
|
||||
this.seaLevel = this.dimension.getSeaLevel();
|
||||
this.ores = null;
|
||||
this.lakes = null;
|
||||
|
@ -1869,17 +1849,6 @@ public final class WorldServer extends AWorldServer {
|
|||
return this.instances.getValueByKey(v) != null;
|
||||
}
|
||||
|
||||
public boolean updateBiomes(int chunkX, int chunkZ) {
|
||||
long v = (long)chunkX + 2147483647L | (long)chunkZ + 2147483647L << 32;
|
||||
PlayerInstance ins = this.instances.getValueByKey(v);
|
||||
if(ins == null)
|
||||
return false;
|
||||
Chunk chunk = this.getChunk(chunkX, chunkZ);
|
||||
chunk.setModified();
|
||||
ins.sendToAllPlayersWatchingChunk(new SPacketBiomes(chunkX, chunkZ, chunk.getBiomes()));
|
||||
return true;
|
||||
}
|
||||
|
||||
private PlayerInstance getPlayerInstance(int chunkX, int chunkZ, boolean create) {
|
||||
long v = (long)chunkX + 2147483647L | (long)chunkZ + 2147483647L << 32;
|
||||
PlayerInstance inst = this.instances.getValueByKey(v);
|
||||
|
@ -2245,29 +2214,6 @@ public final class WorldServer extends AWorldServer {
|
|||
// return new LazyBlock(state, this, position);
|
||||
// }
|
||||
|
||||
public final boolean setBiome(BlockPos position, Biome biome) {
|
||||
Chunk chunk = this.getChunk(position);
|
||||
if((chunk != null) && (chunk.isLoaded())) {
|
||||
chunk.getBiomes()[((position.getZ() & 0xF) << 4 | position.getX() & 0xF)] = (byte)biome.id;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public final void setBiomes(BlockPos start, BlockPos end, Biome biome) {
|
||||
Set<ChunkPos> chunks = Sets.newHashSet();
|
||||
for(int x = start.getX(); x <= end.getX(); x++) {
|
||||
for(int z = start.getZ(); z <= end.getZ(); z++) {
|
||||
if(this.setBiome(new BlockPos(x, 0, z), biome))
|
||||
chunks.add(new ChunkPos(x >> 4, z >> 4));
|
||||
}
|
||||
}
|
||||
for(ChunkPos pos : chunks) {
|
||||
this.updateBiomes(pos.x, pos.z);
|
||||
}
|
||||
chunks.clear();
|
||||
}
|
||||
|
||||
// public final List<? extends Entity> getEntities(EditRegion region) {
|
||||
// List<Entity> entities = Lists.newArrayList();
|
||||
// for(Entity entity : this.entities) {
|
||||
|
@ -2304,10 +2250,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.getHeight(strikePosition).getY() > strikePosition.getY()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -2380,7 +2323,7 @@ public final class WorldServer extends AWorldServer {
|
|||
return false;
|
||||
}
|
||||
else {
|
||||
if(pos.getY() >= 0 && pos.getY() < 512 && this.getLightFor(LightType.BLOCK, pos) < 10) {
|
||||
if(pos.getY() >= 0 && pos.getY() < 512 && this.getLightFor(pos) < 10) {
|
||||
State iblockstate = this.getState(pos);
|
||||
Block block = iblockstate.getBlock();
|
||||
|
||||
|
|
|
@ -5,12 +5,10 @@ import common.init.Blocks;
|
|||
import common.world.State;
|
||||
|
||||
public class ChunkPrimer {
|
||||
public final int height;
|
||||
private final short[] data;
|
||||
|
||||
public ChunkPrimer(int height) {
|
||||
this.data = new short[Math.max(height, 256) * 256];
|
||||
this.height = height;
|
||||
public ChunkPrimer() {
|
||||
this.data = new short[4096];
|
||||
}
|
||||
|
||||
public short[] getData() {
|
||||
|
|
|
@ -5,7 +5,6 @@ import common.init.Blocks;
|
|||
import common.material.Material;
|
||||
import common.rng.Random;
|
||||
import common.util.BlockPos;
|
||||
import common.world.LightType;
|
||||
import common.world.State;
|
||||
import server.biome.GenBiome;
|
||||
import server.world.WorldServer;
|
||||
|
@ -161,7 +160,7 @@ public class FeatureLakes
|
|||
{
|
||||
BlockPos blockpos = position.add(i2, j4 - 1, j3);
|
||||
|
||||
if (worldIn.getState(blockpos).getBlock() == replace && worldIn.getLightFor(LightType.SKY, position.add(i2, j4, j3)) > 0)
|
||||
if (worldIn.getState(blockpos).getBlock() == replace && worldIn.isAirBlock(position.add(i2, j4, j3)))
|
||||
{
|
||||
GenBiome biomegenbase = GenBiome.BIOMES[worldIn.getBiomeGenForCoords(blockpos).id];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue