make light clientside
This commit is contained in:
parent
e3e5fbd7fd
commit
16d20fb31d
54 changed files with 556 additions and 1316 deletions
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
package common.ai;
|
||||
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.util.BlockPos;
|
||||
import common.util.Vec3;
|
||||
import common.village.Village;
|
||||
import common.village.VillageDoorInfo;
|
||||
import common.world.AWorldServer;
|
||||
|
||||
public class EntityAIMoveIndoors extends EntityAIBase
|
||||
{
|
||||
private EntityLiving entityObj;
|
||||
private VillageDoorInfo doorInfo;
|
||||
private int insidePosX = -1;
|
||||
private int insidePosZ = -1;
|
||||
|
||||
public EntityAIMoveIndoors(EntityLiving entityObjIn)
|
||||
{
|
||||
this.entityObj = entityObjIn;
|
||||
this.setMutexBits(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(this.entityObj);
|
||||
|
||||
if ((!((AWorldServer)this.entityObj.worldObj).isDaytime() /* || this.entityObj.worldObj.isRaining() && !this.entityObj.worldObj.getBiomeGenForCoords(blockpos).canRain() */) && this.entityObj.worldObj.dimension.hasSkyLight())
|
||||
{
|
||||
if (this.entityObj.getRNG().zrange(50) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (this.insidePosX != -1 && this.entityObj.getDistanceSq((double)this.insidePosX, this.entityObj.posY, (double)this.insidePosZ) < 4.0D)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Village village = ((AWorldServer)this.entityObj.worldObj).getNearestVillage(blockpos, 14);
|
||||
|
||||
if (village == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.doorInfo = village.getDoorInfo(blockpos);
|
||||
return this.doorInfo != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
return !this.entityObj.getNavigator().noPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
this.insidePosX = -1;
|
||||
BlockPos blockpos = this.doorInfo.getInsideBlockPos();
|
||||
int i = blockpos.getX();
|
||||
int j = blockpos.getY();
|
||||
int k = blockpos.getZ();
|
||||
|
||||
if (this.entityObj.getDistanceSq(blockpos) > 256.0D)
|
||||
{
|
||||
Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockTowards(this.entityObj, 14, 3, new Vec3((double)i + 0.5D, (double)j, (double)k + 0.5D));
|
||||
|
||||
if (vec3 != null)
|
||||
{
|
||||
this.entityObj.getNavigator().tryMoveToXYZ(vec3.xCoord, vec3.yCoord, vec3.zCoord, 1.0D);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.entityObj.getNavigator().tryMoveToXYZ((double)i + 0.5D, (double)j, (double)k + 0.5D, 1.0D);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
this.insidePosX = this.doorInfo.getInsideBlockPos().getX();
|
||||
this.insidePosZ = this.doorInfo.getInsideBlockPos().getZ();
|
||||
this.doorInfo = null;
|
||||
}
|
||||
}
|
|
@ -1,174 +0,0 @@
|
|||
package common.ai;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.collect.Lists;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.pathfinding.PathEntity;
|
||||
import common.pathfinding.PathNavigateGround;
|
||||
import common.util.BlockPos;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Vec3;
|
||||
import common.village.Village;
|
||||
import common.village.VillageDoorInfo;
|
||||
import common.world.AWorldServer;
|
||||
|
||||
public class EntityAIMoveThroughVillage extends EntityAIBase
|
||||
{
|
||||
private EntityLiving theEntity;
|
||||
private double movementSpeed;
|
||||
|
||||
/** The PathNavigate of our entity. */
|
||||
private PathEntity entityPathNavigate;
|
||||
private VillageDoorInfo doorInfo;
|
||||
private boolean isNocturnal;
|
||||
private List<VillageDoorInfo> doorList = Lists.<VillageDoorInfo>newArrayList();
|
||||
|
||||
public EntityAIMoveThroughVillage(EntityLiving theEntityIn, double movementSpeedIn, boolean isNocturnalIn)
|
||||
{
|
||||
this.theEntity = theEntityIn;
|
||||
this.movementSpeed = movementSpeedIn;
|
||||
this.isNocturnal = isNocturnalIn;
|
||||
this.setMutexBits(1);
|
||||
|
||||
if (!(theEntityIn.getNavigator() instanceof PathNavigateGround))
|
||||
{
|
||||
throw new IllegalArgumentException("Unsupported mob for MoveThroughVillageGoal");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
this.resizeDoorList();
|
||||
|
||||
if (this.isNocturnal && ((AWorldServer)this.theEntity.worldObj).isDaytime())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Village village = ((AWorldServer)this.theEntity.worldObj).getNearestVillage(new BlockPos(this.theEntity), 0);
|
||||
|
||||
if (village == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.doorInfo = this.findNearestDoor(village);
|
||||
|
||||
if (this.doorInfo == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
PathNavigateGround pathnavigateground = (PathNavigateGround)this.theEntity.getNavigator();
|
||||
boolean flag = pathnavigateground.getEnterDoors();
|
||||
pathnavigateground.setBreakDoors(false);
|
||||
this.entityPathNavigate = pathnavigateground.getPathToPos(this.doorInfo.getDoorBlockPos());
|
||||
pathnavigateground.setBreakDoors(flag);
|
||||
|
||||
if (this.entityPathNavigate != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockTowards(this.theEntity, 10, 7, new Vec3((double)this.doorInfo.getDoorBlockPos().getX(), (double)this.doorInfo.getDoorBlockPos().getY(), (double)this.doorInfo.getDoorBlockPos().getZ()));
|
||||
|
||||
if (vec3 == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
pathnavigateground.setBreakDoors(false);
|
||||
this.entityPathNavigate = this.theEntity.getNavigator().getPathToXYZ(vec3.xCoord, vec3.yCoord, vec3.zCoord);
|
||||
pathnavigateground.setBreakDoors(flag);
|
||||
return this.entityPathNavigate != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
if (this.theEntity.getNavigator().noPath())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = this.theEntity.width + 4.0F;
|
||||
return this.theEntity.getDistanceSq(this.doorInfo.getDoorBlockPos()) > (double)(f * f);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
this.theEntity.getNavigator().setPath(this.entityPathNavigate, this.movementSpeed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
if (this.theEntity.getNavigator().noPath() || this.theEntity.getDistanceSq(this.doorInfo.getDoorBlockPos()) < 16.0D)
|
||||
{
|
||||
this.doorList.add(this.doorInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private VillageDoorInfo findNearestDoor(Village villageIn)
|
||||
{
|
||||
VillageDoorInfo villagedoorinfo = null;
|
||||
int i = Integer.MAX_VALUE;
|
||||
|
||||
for (VillageDoorInfo villagedoorinfo1 : villageIn.getDoorList())
|
||||
{
|
||||
int j = villagedoorinfo1.getDistanceSquared(ExtMath.floord(this.theEntity.posX), ExtMath.floord(this.theEntity.posY), ExtMath.floord(this.theEntity.posZ));
|
||||
|
||||
if (j < i && !this.doesDoorListContain(villagedoorinfo1))
|
||||
{
|
||||
villagedoorinfo = villagedoorinfo1;
|
||||
i = j;
|
||||
}
|
||||
}
|
||||
|
||||
return villagedoorinfo;
|
||||
}
|
||||
|
||||
private boolean doesDoorListContain(VillageDoorInfo doorInfoIn)
|
||||
{
|
||||
for (VillageDoorInfo villagedoorinfo : this.doorList)
|
||||
{
|
||||
if (doorInfoIn.getDoorBlockPos().equals(villagedoorinfo.getDoorBlockPos()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void resizeDoorList()
|
||||
{
|
||||
if (this.doorList.size() > 15)
|
||||
{
|
||||
this.doorList.remove(0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
package common.ai;
|
||||
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.pathfinding.PathNavigateGround;
|
||||
import common.util.BlockPos;
|
||||
import common.village.Village;
|
||||
import common.village.VillageDoorInfo;
|
||||
import common.world.AWorldServer;
|
||||
|
||||
public class EntityAIRestrictOpenDoor extends EntityAIBase
|
||||
{
|
||||
private EntityLiving entityObj;
|
||||
private VillageDoorInfo frontDoor;
|
||||
|
||||
public EntityAIRestrictOpenDoor(EntityLiving creatureIn)
|
||||
{
|
||||
this.entityObj = creatureIn;
|
||||
|
||||
if (!(creatureIn.getNavigator() instanceof PathNavigateGround))
|
||||
{
|
||||
throw new IllegalArgumentException("Unsupported mob type for RestrictOpenDoorGoal");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
if (((AWorldServer)this.entityObj.worldObj).isDaytime())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(this.entityObj);
|
||||
Village village = ((AWorldServer)this.entityObj.worldObj).getNearestVillage(blockpos, 16);
|
||||
|
||||
if (village == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.frontDoor = village.getNearestDoor(blockpos);
|
||||
return this.frontDoor == null ? false : (double)this.frontDoor.getDistanceToInsideBlockSq(blockpos) < 2.25D;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
return ((AWorldServer)this.entityObj.worldObj).isDaytime() ? false : !this.frontDoor.getIsDetachedFromVillageFlag() && this.frontDoor.isIndoorSide(new BlockPos(this.entityObj));
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
((PathNavigateGround)this.entityObj.getNavigator()).setBreakDoors(false);
|
||||
((PathNavigateGround)this.entityObj.getNavigator()).setEnterDoors(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
((PathNavigateGround)this.entityObj.getNavigator()).setBreakDoors(true);
|
||||
((PathNavigateGround)this.entityObj.getNavigator()).setEnterDoors(true);
|
||||
this.frontDoor = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
public void updateTask()
|
||||
{
|
||||
this.frontDoor.incrementDoorOpeningRestrictionCounter();
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -21,13 +21,13 @@ public class BlockBlackenedSoil extends BlockSnowable
|
|||
|
||||
public void tick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
|
||||
{
|
||||
if (worldIn.getLightFromNeighbors(pos.up()) < 2 && worldIn.getState(pos.up()).getBlock().getLightOpacity() > 6)
|
||||
if (worldIn.getState(pos.up()).getBlock().getLightOpacity() > 6)
|
||||
{
|
||||
if(Vars.darkSoilDecay)
|
||||
worldIn.setState(pos, Blocks.blackened_dirt.getState());
|
||||
}
|
||||
else {
|
||||
if (Vars.darkSoilSpread && worldIn.getLightFromNeighbors(pos.up()) >= 1)
|
||||
if (Vars.darkSoilSpread)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ public class BlockBlackenedSoil extends BlockSnowable
|
|||
Block block = worldIn.getState(blockpos.up()).getBlock();
|
||||
State iblockstate = worldIn.getState(blockpos);
|
||||
|
||||
if ((iblockstate.getBlock() == Blocks.dirt || iblockstate.getBlock() == Blocks.grass || iblockstate.getBlock() == Blocks.swamp || iblockstate.getBlock() == Blocks.blackened_dirt) && worldIn.getLightFromNeighbors(blockpos.up()) >= 2 && block.getLightOpacity() <= 6)
|
||||
if ((iblockstate.getBlock() == Blocks.dirt || iblockstate.getBlock() == Blocks.grass || iblockstate.getBlock() == Blocks.swamp || iblockstate.getBlock() == Blocks.blackened_dirt) && block.getLightOpacity() <= 6)
|
||||
{
|
||||
worldIn.setState(blockpos, Blocks.blackened_soil.getState());
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class BlockBlueShroom extends BlockBush
|
|||
if (pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y)
|
||||
{
|
||||
State iblockstate = worldIn.getState(pos.down());
|
||||
return (iblockstate.getBlock() == Blocks.tian_soil || iblockstate.getBlock() == Blocks.obsidian) ? true : (worldIn.getLight(pos) < 13 && this.canPlaceBlockOn(iblockstate.getBlock()));
|
||||
return (iblockstate.getBlock() == Blocks.tian_soil || iblockstate.getBlock() == Blocks.obsidian) ? true : this.canPlaceBlockOn(iblockstate.getBlock());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -46,7 +46,7 @@ public class BlockCrops extends BlockBush implements IGrowable
|
|||
{
|
||||
super.tick(worldIn, pos, state, rand);
|
||||
|
||||
if (Vars.cropGrowth > 0 && worldIn.getLightFromNeighbors(pos.up()) >= 9)
|
||||
if (Vars.cropGrowth > 0)
|
||||
{
|
||||
int i = ((Integer)state.getValue(AGE)).intValue();
|
||||
|
||||
|
@ -131,7 +131,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 getCrop()
|
||||
|
|
|
@ -22,7 +22,7 @@ public class BlockGrass extends BlockSnowable implements IGrowable
|
|||
|
||||
public void tick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
|
||||
{
|
||||
if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getState(pos.up()).getBlock().getLightOpacity() > 2)
|
||||
if (worldIn.getState(pos.up()).getBlock().getLightOpacity() > 2)
|
||||
{
|
||||
if(Vars.grassDecay)
|
||||
worldIn.setState(pos, Blocks.dirt.getState());
|
||||
|
@ -34,7 +34,7 @@ public class BlockGrass extends BlockSnowable implements IGrowable
|
|||
}
|
||||
else
|
||||
{
|
||||
if (Vars.grassSpread && worldIn.getLightFromNeighbors(pos.up()) >= 9)
|
||||
if (Vars.grassSpread)
|
||||
{
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ public class BlockGrass extends BlockSnowable implements IGrowable
|
|||
Block block = worldIn.getState(blockpos.up()).getBlock();
|
||||
State iblockstate = worldIn.getState(blockpos);
|
||||
|
||||
if (iblockstate.getBlock() == Blocks.dirt && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && block.getLightOpacity() <= 2)
|
||||
if (iblockstate.getBlock() == Blocks.dirt && block.getLightOpacity() <= 2)
|
||||
{
|
||||
worldIn.setState(blockpos, Blocks.grass.getState());
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public class BlockMushroom extends BlockBush implements IGrowable
|
|||
if (pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y)
|
||||
{
|
||||
State iblockstate = worldIn.getState(pos.down());
|
||||
return iblockstate.getBlock() == Blocks.mycelium ? true : (iblockstate.getBlock() == Blocks.podzol ? true : worldIn.getLight(pos) < 13 && this.canPlaceBlockOn(iblockstate.getBlock()));
|
||||
return iblockstate.getBlock() == Blocks.mycelium ? true : (iblockstate.getBlock() == Blocks.podzol ? true : this.canPlaceBlockOn(iblockstate.getBlock()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@ public class BlockMycelium extends BlockSnowable
|
|||
{
|
||||
// if (!worldIn.client)
|
||||
// {
|
||||
if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getState(pos.up()).getBlock().getLightOpacity() > 2)
|
||||
if (worldIn.getState(pos.up()).getBlock().getLightOpacity() > 2)
|
||||
{
|
||||
if(Vars.mycelDecay)
|
||||
worldIn.setState(pos, Blocks.dirt.getState());
|
||||
|
@ -33,20 +33,17 @@ public class BlockMycelium extends BlockSnowable
|
|||
else {
|
||||
if(Vars.mycelSpread)
|
||||
{
|
||||
if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
|
||||
{
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
BlockPos blockpos = pos.add(rand.zrange(3) - 1, rand.zrange(5) - 3, rand.zrange(3) - 1);
|
||||
State iblockstate = worldIn.getState(blockpos);
|
||||
Block block = worldIn.getState(blockpos.up()).getBlock();
|
||||
|
||||
if (iblockstate.getBlock() == Blocks.dirt && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && block.getLightOpacity() <= 2)
|
||||
{
|
||||
worldIn.setState(blockpos, this.getState());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
BlockPos blockpos = pos.add(rand.zrange(3) - 1, rand.zrange(5) - 3, rand.zrange(3) - 1);
|
||||
State iblockstate = worldIn.getState(blockpos);
|
||||
Block block = worldIn.getState(blockpos.up()).getBlock();
|
||||
|
||||
if (iblockstate.getBlock() == Blocks.dirt && block.getLightOpacity() <= 2)
|
||||
{
|
||||
worldIn.setState(blockpos, this.getState());
|
||||
}
|
||||
}
|
||||
}
|
||||
super.tick(worldIn, pos, state, rand);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class BlockSapling extends BlockBush implements IGrowable
|
|||
// {
|
||||
super.tick(worldIn, pos, state, rand);
|
||||
|
||||
if (Vars.treeGrowth > 0 && worldIn.getLightFromNeighbors(pos.up()) >= 9 && rand.chance(Vars.treeGrowth))
|
||||
if (Vars.treeGrowth > 0 && rand.chance(Vars.treeGrowth))
|
||||
{
|
||||
this.grow(worldIn, pos, state, rand);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class BlockStem extends BlockBush implements IGrowable
|
|||
{
|
||||
super.tick(worldIn, pos, state, rand);
|
||||
|
||||
if (Vars.stemGrowth > 0 && worldIn.getLightFromNeighbors(pos.up()) >= 9)
|
||||
if (Vars.stemGrowth > 0)
|
||||
{
|
||||
float f = BlockCrops.getGrowthChance(this, worldIn, pos);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public class BlockSwamp extends BlockSnowable
|
|||
|
||||
public void tick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
|
||||
{
|
||||
if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getState(pos.up()).getBlock().getLightOpacity() > 2)
|
||||
if (worldIn.getState(pos.up()).getBlock().getLightOpacity() > 2)
|
||||
{
|
||||
if(Vars.swampDecay)
|
||||
worldIn.setState(pos, Blocks.dirt.getState());
|
||||
|
|
|
@ -33,7 +33,7 @@ public class BlockBlackenedDirt extends BlockNonBlock
|
|||
{
|
||||
worldIn.setState(blockpos, Blocks.blackened_dirt.getState());
|
||||
}
|
||||
else if ((iblockstate.getBlock() == Blocks.grass || iblockstate.getBlock() == Blocks.swamp) && worldIn.getLightFromNeighbors(blockpos.up()) >= 2 && block.getLightOpacity() <= 6)
|
||||
else if ((iblockstate.getBlock() == Blocks.grass || iblockstate.getBlock() == Blocks.swamp) && block.getLightOpacity() <= 6)
|
||||
{
|
||||
worldIn.setState(blockpos, Blocks.blackened_soil.getState());
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class BlockIce extends BlockNonBlock {
|
|||
}
|
||||
|
||||
public void tick(AWorldServer world, BlockPos pos, State state, Random rand) {
|
||||
if(Vars.iceMelt && (world.getLightFor(pos) > 11 - this.getLightOpacity() || !world.canFreezeAt(pos))) {
|
||||
if(Vars.iceMelt && !world.canFreezeAt(pos)) {
|
||||
if(world.doesWaterVaporize(pos)) {
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ public class BlockSnow extends Block
|
|||
|
||||
public void tick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
|
||||
{
|
||||
if (Vars.snowMelt && (worldIn.getLightFor(pos) > 11 || !worldIn.canFreezeAt(pos)))
|
||||
if (Vars.snowMelt && !worldIn.canFreezeAt(pos))
|
||||
{
|
||||
this.drop(worldIn, pos, worldIn.getState(pos), 0);
|
||||
worldIn.setBlockToAir(pos);
|
||||
|
|
|
@ -27,7 +27,7 @@ public class BlockSnowBlock extends BlockNonBlock {
|
|||
}
|
||||
|
||||
public void tick(AWorldServer world, BlockPos pos, State state, Random rand) {
|
||||
if(Vars.snowFullMelt && (world.getLightFor(pos) > 11 || !world.canFreezeAt(pos))) {
|
||||
if(Vars.snowFullMelt && !world.canFreezeAt(pos)) {
|
||||
this.drop(world, pos, world.getState(pos), 0);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
|
|
@ -270,20 +270,7 @@ public class EntityBat extends EntityLiving
|
|||
}
|
||||
else
|
||||
{
|
||||
int i = this.worldObj.getLightFromNeighbors(blockpos);
|
||||
int j = 4;
|
||||
|
||||
// if (Config.useHalloween && isDateAroundHalloween(World.getCurrentDate()))
|
||||
// {
|
||||
// j = 7;
|
||||
// }
|
||||
// else
|
||||
if (this.rand.chance())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return i <= this.rand.zrange(j); // ? false : super.getCanSpawnHere();
|
||||
return this.rand.chance();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,22 +91,10 @@ public class EntityMouse extends EntityAnimal {
|
|||
protected int getExperiencePoints(EntityNPC player) {
|
||||
return this.worldObj.rand.range(0, 1);
|
||||
}
|
||||
|
||||
public boolean getCanSpawnHere()
|
||||
{
|
||||
if (((int)this.getEntityBoundingBox().minY) >= this.worldObj.getSeaLevel())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.getCanSpawnHere();
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isValidLightLevel(int level)
|
||||
protected boolean isValidSpawnHeight(int y)
|
||||
{
|
||||
return level < 6;
|
||||
return y < this.worldObj.getSeaLevel();
|
||||
}
|
||||
|
||||
public float getBlockPathWeight(BlockPos pos)
|
||||
|
|
|
@ -147,7 +147,7 @@ public class EntityArachnoid extends EntityNPC {
|
|||
}
|
||||
|
||||
public boolean getCanSpawnHere() {
|
||||
return this.worldObj.getLightFromNeighbors(new BlockPos(this)) <= this.rand.zrange(8);
|
||||
return (int)this.posY < this.worldObj.getSeaLevel() || this.rand.chance(6);
|
||||
}
|
||||
|
||||
public boolean canAmbush(EntityLiving entity) {
|
||||
|
|
|
@ -11,7 +11,6 @@ import common.rng.Random;
|
|||
import common.tags.TagObject;
|
||||
import common.vars.Vars;
|
||||
import common.world.World;
|
||||
import common.world.AWorldServer;
|
||||
|
||||
public class EntityHaunter extends EntityNPC {
|
||||
// private int lastActiveTime;
|
||||
|
@ -334,10 +333,6 @@ public class EntityHaunter extends EntityNPC {
|
|||
public boolean isGhost() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean getCanSpawnHere() {
|
||||
return !((AWorldServer)this.worldObj).isDaytime();
|
||||
}
|
||||
|
||||
// public boolean canAmbush(EntityLiving entity) {
|
||||
// return true;
|
||||
|
|
|
@ -392,7 +392,7 @@ public class EntitySlime extends EntityNPC
|
|||
// {
|
||||
// if (this.worldObj.getDifficulty() != Difficulty.PEACEFUL)
|
||||
// {
|
||||
if (this.worldObj.getState(new BlockPos(this.posX, this.getEntityBoundingBox().minY - 1.0, this.posZ)).getBlock() == Blocks.swamp && this.posY > 50.0D && this.posY < 70.0D && this.rand.floatv() < 0.5F && this.rand.floatv() < this.worldObj.getMoonPhase() && this.worldObj.getLightFromNeighbors(new BlockPos(this)) <= this.rand.zrange(8))
|
||||
if (this.worldObj.getState(new BlockPos(this.posX, this.getEntityBoundingBox().minY - 1.0, this.posZ)).getBlock() == Blocks.swamp && this.posY > 50.0D && this.posY < 70.0D && this.rand.floatv() < 0.5F && this.rand.floatv() < this.worldObj.getMoonPhase())
|
||||
{
|
||||
return super.getCanSpawnHere();
|
||||
}
|
||||
|
|
|
@ -104,10 +104,6 @@ public class EntityUndead extends EntityNPC
|
|||
public Alignment getNaturalAlign() {
|
||||
return Alignment.EVIL;
|
||||
}
|
||||
|
||||
public boolean getCanSpawnHere() {
|
||||
return !((AWorldServer)this.worldObj).isDaytime();
|
||||
}
|
||||
|
||||
// public boolean canAmbush(EntityLiving entity) {
|
||||
// return true;
|
||||
|
|
|
@ -3,7 +3,6 @@ package common.entity.npc;
|
|||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import common.ai.EntityAIMoveThroughVillage;
|
||||
import common.entity.DamageSource;
|
||||
import common.entity.animal.EntityChicken;
|
||||
import common.entity.types.EntityLiving;
|
||||
|
@ -19,7 +18,6 @@ public class EntityZombie extends EntityNPC
|
|||
public EntityZombie(World worldIn)
|
||||
{
|
||||
super(worldIn);
|
||||
this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false));
|
||||
}
|
||||
|
||||
protected void applyEntityAttributes()
|
||||
|
@ -66,7 +64,7 @@ public class EntityZombie extends EntityNPC
|
|||
int j1 = j + this.rand.range(7, 40) * this.rand.range(-1, 1);
|
||||
int k1 = k + this.rand.range(7, 40) * this.rand.range(-1, 1);
|
||||
|
||||
if (this.worldObj.isBlockSolid(new BlockPos(i1, j1 - 1, k1)) && this.worldObj.getLightFromNeighbors(new BlockPos(i1, j1, k1)) < 10)
|
||||
if (this.worldObj.isBlockSolid(new BlockPos(i1, j1 - 1, k1)))
|
||||
{
|
||||
entityzombie.setPosition((double)i1, (double)j1, (double)k1);
|
||||
|
||||
|
@ -312,10 +310,6 @@ public class EntityZombie extends EntityNPC
|
|||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.CHAOTIC_EVIL, Alignment.EVIL);
|
||||
}
|
||||
|
||||
public boolean getCanSpawnHere() {
|
||||
return !((AWorldServer)this.worldObj).isDaytime();
|
||||
}
|
||||
|
||||
// public boolean canAmbush(EntityLiving entity) {
|
||||
// return true;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -117,12 +117,12 @@ public abstract class EntityAnimal extends EntityLiving
|
|||
int j = ExtMath.floord(this.getEntityBoundingBox().minY);
|
||||
int k = ExtMath.floord(this.posZ);
|
||||
BlockPos blockpos = new BlockPos(i, j, k);
|
||||
return this.spawnableBlocks.contains(this.worldObj.getState(blockpos.down()).getBlock()) && this.isValidLightLevel(this.worldObj.getLight(blockpos)) && super.getCanSpawnHere();
|
||||
return this.spawnableBlocks.contains(this.worldObj.getState(blockpos.down()).getBlock()) && this.isValidSpawnHeight(blockpos.getY()) && super.getCanSpawnHere();
|
||||
}
|
||||
|
||||
protected boolean isValidLightLevel(int level)
|
||||
protected boolean isValidSpawnHeight(int y)
|
||||
{
|
||||
return level > 8;
|
||||
return y >= this.worldObj.getSeaLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -71,9 +71,8 @@ public class SPacketChunkData implements Packet<IClientPlayer>
|
|||
public static int getSize(int segments, boolean biomes)
|
||||
{
|
||||
int i = segments * 2 * 16 * 16 * 16;
|
||||
int j = segments * 16 * 16 * 16 / 2;
|
||||
int l = biomes ? 256 * 8 : 0;
|
||||
return i + j + l;
|
||||
return i + l;
|
||||
}
|
||||
|
||||
public int getChunkX()
|
||||
|
|
|
@ -155,7 +155,7 @@ public abstract class PathNavigate
|
|||
this.currentPath = pathentityIn;
|
||||
}
|
||||
|
||||
this.removeSunnyPath();
|
||||
this.removeInvalidPath();
|
||||
|
||||
if (this.currentPath.getCurrentPathLength() == 0)
|
||||
{
|
||||
|
@ -314,10 +314,7 @@ 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()
|
||||
protected void removeInvalidPath()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import common.world.World;
|
|||
public class PathNavigateGround extends PathNavigate
|
||||
{
|
||||
protected WalkNodeProcessor nodeProcessor;
|
||||
private boolean shouldAvoidSun;
|
||||
|
||||
public PathNavigateGround(EntityLiving entitylivingIn, World worldIn)
|
||||
{
|
||||
|
@ -72,33 +71,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
|
||||
|
@ -287,9 +259,4 @@ public class PathNavigateGround extends PathNavigate
|
|||
{
|
||||
return this.nodeProcessor.getCanSwim();
|
||||
}
|
||||
|
||||
public void setAvoidSun(boolean par1)
|
||||
{
|
||||
this.shouldAvoidSun = par1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,8 +44,6 @@ public abstract class AWorldServer extends World {
|
|||
public abstract void addToVillagerPositionList(BlockPos blockpos);
|
||||
public abstract boolean isPlayerWatchingChunk(EntityNPC player, int chunkX, int chunkZ);
|
||||
public abstract void sendToAllTrackingEntity(Entity entityIn, Packet packet);
|
||||
public abstract boolean isDaytime();
|
||||
public abstract int getSkylightSubtracted();
|
||||
public abstract <T extends Entity> T findNearestEntityWithinAABB(Class<? extends T> entityType, BoundingBox aabb, T closestTo);
|
||||
public abstract void markChunkDirty(BlockPos pos);
|
||||
public abstract void growGrass(BlockPos pos, State state, Random rand);
|
||||
|
|
|
@ -21,7 +21,6 @@ public class BlockArray {
|
|||
this.yBase = y;
|
||||
this.filler = filler;
|
||||
this.data = new char[4096];
|
||||
this.blocklight = new NibbleArray();
|
||||
if(filler != null && filler.getBlock() != Blocks.air) {
|
||||
Arrays.fill(this.data, (char)BlockRegistry.getId(filler));
|
||||
this.blocks = this.data.length;
|
||||
|
@ -75,14 +74,6 @@ public class BlockArray {
|
|||
return this.yBase;
|
||||
}
|
||||
|
||||
public void setLight(int x, int y, int z, int value) {
|
||||
this.blocklight.set(x, y, z, value);
|
||||
}
|
||||
|
||||
public int getLight(int x, int y, int z) {
|
||||
return this.blocklight.get(x, y, z);
|
||||
}
|
||||
|
||||
public void update() {
|
||||
this.blocks = 0;
|
||||
this.ticked = 0;
|
||||
|
@ -108,17 +99,9 @@ public class BlockArray {
|
|||
return this.data;
|
||||
}
|
||||
|
||||
public NibbleArray getBlocklight() {
|
||||
return this.blocklight;
|
||||
}
|
||||
|
||||
public void setData(char[] data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public void setBlocklight(NibbleArray data) {
|
||||
this.blocklight = data;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.yBase >> 4;
|
||||
|
@ -127,4 +110,18 @@ public class BlockArray {
|
|||
public boolean equals(Object other) {
|
||||
return other instanceof BlockArray && ((BlockArray)other).yBase == this.yBase;
|
||||
}
|
||||
|
||||
public void setLight(int x, int y, int z, int value) {
|
||||
if(this.blocklight == null)
|
||||
this.blocklight = new NibbleArray();
|
||||
this.blocklight.set(x, y, z, value);
|
||||
}
|
||||
|
||||
public int getLight(int x, int y, int z) {
|
||||
return this.blocklight == null ? 0 : this.blocklight.get(x, y, z);
|
||||
}
|
||||
|
||||
public void clearLight() {
|
||||
this.blocklight = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import common.block.Block;
|
||||
|
@ -34,11 +33,8 @@ public abstract class Chunk {
|
|||
protected final int[] height = new int[256];
|
||||
protected final Map<BlockPos, TileEntity> tiles = Maps.<BlockPos, TileEntity>newHashMap();
|
||||
protected final InheritanceMultiMap<Entity>[] entities = new InheritanceMultiMap[32];
|
||||
protected final ConcurrentLinkedQueue<BlockPos> tileQueue = new ConcurrentLinkedQueue<BlockPos>();
|
||||
|
||||
protected boolean loaded;
|
||||
protected boolean populated;
|
||||
protected boolean updated;
|
||||
protected boolean modified;
|
||||
protected boolean hasEntity;
|
||||
protected int minHeight;
|
||||
|
@ -75,7 +71,7 @@ public abstract class Chunk {
|
|||
this.top = y > this.top ? y : this.top;
|
||||
}
|
||||
|
||||
public void genSky() {
|
||||
public void genHeightMap() {
|
||||
int top = this.top;
|
||||
int bottom = this.bottom < -64 ? -64 : this.bottom;
|
||||
this.minHeight = Integer.MAX_VALUE;
|
||||
|
@ -101,7 +97,7 @@ public abstract class Chunk {
|
|||
this.modified = true;
|
||||
}
|
||||
|
||||
private void relightBlock(int x, int y, int z) {
|
||||
private void updateHeight(int x, int y, int z) {
|
||||
int h = this.height[z << 4 | x];
|
||||
int min = this.bottom < -64 ? -64 : this.bottom;
|
||||
int cy = h;
|
||||
|
@ -159,7 +155,7 @@ public abstract class Chunk {
|
|||
return this.getBlock0(pos.getX() & 15, pos.getY(), pos.getZ() & 15);
|
||||
}
|
||||
|
||||
public State setState(BlockPos pos, State state, boolean updateLight) {
|
||||
public State setState(BlockPos pos, State state, boolean updateHeight) {
|
||||
int x = pos.getX() & 15;
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ() & 15;
|
||||
|
@ -206,9 +202,9 @@ public abstract class Chunk {
|
|||
return null;
|
||||
}
|
||||
else {
|
||||
if(updateLight) {
|
||||
if(updateHeight) {
|
||||
if(up) {
|
||||
this.genSky();
|
||||
this.genHeightMap();
|
||||
}
|
||||
else {
|
||||
int b = block.getLightOpacity();
|
||||
|
@ -216,11 +212,11 @@ public abstract class Chunk {
|
|||
|
||||
if(b > 0) {
|
||||
if(y >= h) {
|
||||
this.relightBlock(x, y + 1, z);
|
||||
this.updateHeight(x, y + 1, z);
|
||||
}
|
||||
}
|
||||
else if(y == h - 1) {
|
||||
this.relightBlock(x, y, z);
|
||||
this.updateHeight(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -256,44 +252,6 @@ public abstract class Chunk {
|
|||
}
|
||||
}
|
||||
|
||||
public int getLight(BlockPos pos) {
|
||||
int x = pos.getX() & 15;
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ() & 15;
|
||||
BlockArray stor = this.getArray(y >> 4);
|
||||
return stor == null ? 0 : stor.getLight(x, y & 15, z);
|
||||
}
|
||||
|
||||
public void setLight(BlockPos pos, int value) {
|
||||
int x = pos.getX() & 15;
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ() & 15;
|
||||
BlockArray stor = this.getArray(y >> 4);
|
||||
|
||||
if(stor == null) {
|
||||
stor = new BlockArray(y >> 4 << 4, y < 0 ? this.filler : null);
|
||||
this.setArray(stor);
|
||||
this.genSky();
|
||||
}
|
||||
|
||||
this.modified = true;
|
||||
|
||||
stor.setLight(x, y & 15, z, value);
|
||||
}
|
||||
|
||||
public int getLightSub(BlockPos pos, int amount) {
|
||||
int x = pos.getX() & 15;
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ() & 15;
|
||||
BlockArray stor = this.getArray(y >> 4);
|
||||
int l = this.world.dimension.hasSkyLight() ? World.getSkyLightFor(pos.getY()) : 0;
|
||||
if(stor == null)
|
||||
return this.world.dimension.hasSkyLight() && amount < l ? l - amount : 0;
|
||||
l = l - amount;
|
||||
int b = stor.getLight(x, y & 15, z);
|
||||
return b > l ? b : l;
|
||||
}
|
||||
|
||||
public void addEntity(Entity entity) {
|
||||
this.hasEntity = true;
|
||||
int x = ExtMath.floord(entity.posX / 16.0D);
|
||||
|
@ -336,14 +294,7 @@ public abstract 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) {
|
||||
protected TileEntity createNewTileEntity(BlockPos pos) {
|
||||
Block block = this.getBlock(pos);
|
||||
return !(block instanceof ITileEntityProvider provider) ? null : provider.createNewTileEntity();
|
||||
}
|
||||
|
@ -356,9 +307,6 @@ public abstract class Chunk {
|
|||
tile = this.createNewTileEntity(pos);
|
||||
this.world.setTileEntity(pos, tile);
|
||||
}
|
||||
else if(type == TileEntity.CreateMode.QUEUED) {
|
||||
this.tileQueue.add(pos);
|
||||
}
|
||||
}
|
||||
else if(tile.isInvalid()) {
|
||||
this.tiles.remove(pos);
|
||||
|
@ -470,24 +418,6 @@ public abstract class Chunk {
|
|||
return new BlockPos(pos.getX(), this.precHeight[o], pos.getZ());
|
||||
}
|
||||
|
||||
public void update(boolean noGaps) {
|
||||
this.updated = true;
|
||||
|
||||
while(!this.tileQueue.isEmpty()) {
|
||||
BlockPos pos = (BlockPos)this.tileQueue.poll();
|
||||
|
||||
if(this.getTileEntity(pos, TileEntity.CreateMode.CHECK) == null && this.getBlock(pos) instanceof ITileEntityProvider) {
|
||||
TileEntity tile = this.createNewTileEntity(pos);
|
||||
this.world.setTileEntity(pos, tile);
|
||||
this.world.markBlockRangeForRenderUpdate(pos, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPopulated() {
|
||||
return this.updated && this.populated;
|
||||
}
|
||||
|
||||
public boolean isLoaded() {
|
||||
return this.loaded;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ import common.tileentity.TileEntity;
|
|||
import common.util.BlockPos;
|
||||
import common.util.BoundingBox;
|
||||
import common.util.ChunkPos;
|
||||
import common.util.Clientside;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Facing;
|
||||
import common.util.HitPosition;
|
||||
|
@ -42,7 +41,6 @@ import common.util.Vec3;
|
|||
import common.vars.Vars;
|
||||
|
||||
public abstract class World implements IWorldAccess {
|
||||
public static final float[] BRIGHTNESS = new float[] {0.0f, 0.02f, 0.04f, 0.06f, 0.08f, 0.11f, 0.14f, 0.18f, 0.22f, 0.27f, 0.33f, 0.41f, 0.5f, 0.62f, 0.78f, 1.0f};
|
||||
public static final float[] MOON_PHASES = new float[] {1.0F, 0.75F, 0.5F, 0.25F, 0.0F, 0.25F, 0.5F, 0.75F};
|
||||
public static final int MAX_SIZE = 67108864;
|
||||
public static final int MAX_SIZE_Y = 4096;
|
||||
|
@ -60,12 +58,10 @@ public abstract class World implements IWorldAccess {
|
|||
public final List<Entity> effects = Lists.<Entity>newArrayList();
|
||||
public final IntHashMap<Entity> entityIds = new IntHashMap();
|
||||
protected final Set<ChunkPos> active = Sets.<ChunkPos>newHashSet();
|
||||
protected final int[] lightUpdate = new int[32768];
|
||||
public final Dimension dimension;
|
||||
|
||||
protected double gravity = 1.0;
|
||||
protected boolean loadTiles;
|
||||
protected int subtract;
|
||||
protected float rain;
|
||||
protected float darkness;
|
||||
protected float fog;
|
||||
|
@ -183,11 +179,18 @@ public abstract class World implements IWorldAccess {
|
|||
Block block1 = iblockstate.getBlock();
|
||||
if(block.getLightOpacity() != block1.getLightOpacity() || block.getLight() != block1.getLight())
|
||||
this.checkBlockLight(pos);
|
||||
if((flags & 2) != 0 && (flags & 4) == 0 && chunk.isPopulated())
|
||||
if((flags & 2) != 0 && (flags & 4) == 0)
|
||||
this.markBlockForUpdate(pos);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void checkBlockLight(BlockPos pos) {
|
||||
}
|
||||
|
||||
public int getCombinedLight(BlockPos pos, int lightValue) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean setState(BlockPos pos, State state) {
|
||||
return this.setState(pos, state, 3);
|
||||
}
|
||||
|
@ -228,174 +231,6 @@ public abstract class World implements IWorldAccess {
|
|||
this.clientRenderUpdate(rangeMin.getX(), rangeMin.getY(), rangeMin.getZ(), rangeMax.getX(), rangeMax.getY(), rangeMax.getZ());
|
||||
}
|
||||
|
||||
public boolean canSeeSky(BlockPos pos) {
|
||||
return this.getChunk(pos).canSeeSky(pos);
|
||||
}
|
||||
|
||||
public int getLight(BlockPos pos) {
|
||||
if(pos.getY() < -MAX_SIZE_Y) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
if(pos.getY() >= MAX_SIZE_Y) {
|
||||
pos = new BlockPos(pos.getX(), MAX_SIZE_Y - 1, pos.getZ());
|
||||
}
|
||||
|
||||
return this.getChunk(pos).getLightSub(pos, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public int getLightFromNeighbors(BlockPos pos) {
|
||||
return this.getLight(pos, true);
|
||||
}
|
||||
|
||||
private int getLight(BlockPos pos, boolean checkNeighbors) {
|
||||
if(pos.getX() >= -MAX_SIZE && pos.getZ() >= -MAX_SIZE && pos.getX() < MAX_SIZE && pos.getZ() < MAX_SIZE) {
|
||||
if(checkNeighbors && this.getState(pos).getBlock().getSumBrightness()) {
|
||||
int i1 = this.getLight(pos.up(), false);
|
||||
int i = this.getLight(pos.east(), false);
|
||||
int j = this.getLight(pos.west(), false);
|
||||
int k = this.getLight(pos.south(), false);
|
||||
int l = this.getLight(pos.north(), false);
|
||||
|
||||
if(i > i1) {
|
||||
i1 = i;
|
||||
}
|
||||
|
||||
if(j > i1) {
|
||||
i1 = j;
|
||||
}
|
||||
|
||||
if(k > i1) {
|
||||
i1 = k;
|
||||
}
|
||||
|
||||
if(l > i1) {
|
||||
i1 = l;
|
||||
}
|
||||
|
||||
return i1;
|
||||
}
|
||||
else if(pos.getY() < -MAX_SIZE_Y) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
if(pos.getY() >= MAX_SIZE_Y) {
|
||||
pos = new BlockPos(pos.getX(), MAX_SIZE_Y - 1, pos.getZ());
|
||||
}
|
||||
|
||||
Chunk chunk = this.getChunk(pos);
|
||||
return chunk.getLightSub(pos, this.subtract);
|
||||
}
|
||||
}
|
||||
else {
|
||||
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 getBlockLightSum(BlockPos pos) {
|
||||
if(pos.getY() < -MAX_SIZE_Y) {
|
||||
pos = new BlockPos(pos.getX(), -MAX_SIZE_Y, pos.getZ());
|
||||
}
|
||||
|
||||
if(!isValid(pos)) {
|
||||
return 0;
|
||||
}
|
||||
else if(!this.isBlockLoaded(pos)) {
|
||||
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(pos);
|
||||
}
|
||||
}
|
||||
|
||||
public int getLightFor(BlockPos pos) {
|
||||
if(pos.getY() < -MAX_SIZE_Y) {
|
||||
pos = new BlockPos(pos.getX(), -MAX_SIZE_Y, 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 setBlockLight(BlockPos pos, int lightValue) {
|
||||
if(isValid(pos)) {
|
||||
if(this.isBlockLoaded(pos)) {
|
||||
Chunk chunk = this.getChunk(pos);
|
||||
chunk.setLight(pos, lightValue);
|
||||
this.clientNotifyLight(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Clientside
|
||||
public int getCombinedLight(BlockPos pos, int lightValue) {
|
||||
int i = this.dimension.hasSkyLight() ? getSkyLightFor(pos.getY()) : 0;
|
||||
int j = this.getBlockLightSum(pos);
|
||||
|
||||
if(j < lightValue) {
|
||||
j = lightValue;
|
||||
}
|
||||
|
||||
return i << 20 | j << 4;
|
||||
}
|
||||
|
||||
public float getLightBrightness(BlockPos pos) {
|
||||
return Math.max(BRIGHTNESS[this.getLightFromNeighbors(pos)], (float)this.dimension.getBrightness() / 15.0f);
|
||||
}
|
||||
|
||||
public State getState(BlockPos pos) {
|
||||
if(!isValid(pos)) {
|
||||
return Blocks.air.getState();
|
||||
|
@ -759,39 +594,6 @@ public abstract class World implements IWorldAccess {
|
|||
return list;
|
||||
}
|
||||
|
||||
private float calcRotationPhase(long worldTime, float partial) {
|
||||
int i = (int)(worldTime % this.dimension.getRotationalPeriod());
|
||||
float f = ((float)i + partial) / (float)this.dimension.getRotationalPeriod() - 0.5F;
|
||||
|
||||
if(f < 0.0F) {
|
||||
++f;
|
||||
}
|
||||
|
||||
if(f > 1.0F) {
|
||||
--f;
|
||||
}
|
||||
|
||||
f = 1.0F - (float)((Math.cos((double)f * Math.PI) + 1.0D) / 2.0D);
|
||||
f = f + (f - f) / 3.0F;
|
||||
return f;
|
||||
}
|
||||
|
||||
public int calcSkylightSubtracted(boolean current) {
|
||||
float f = !this.dimension.hasDaylight() || (current && this.dimension.isBaseDestroyed()) ? 0.5f : this.calcRotationPhase(current ? this.rotation :
|
||||
(this.dimension.getRotationalPeriod() / 4L), 1.0f);
|
||||
float f1 = 1.0F - (ExtMath.cos(f * (float)Math.PI * 2.0F) * 2.0F + 0.5F);
|
||||
f1 = ExtMath.clampf(f1, 0.0F, 1.0F);
|
||||
f1 = 1.0F - f1;
|
||||
f1 = (float)((double)f1 * (1.0D - (double)(this.getRainStrength() * 5.0F) / 16.0D));
|
||||
f1 = (float)((double)f1 * (1.0D - (double)(this.getDarkness() * 5.0F) / 16.0D));
|
||||
f1 = 1.0F - f1;
|
||||
return (int)(f1 * 11.0F);
|
||||
}
|
||||
|
||||
public float getCelestialAngle(float partial) {
|
||||
return !this.dimension.hasRotation() ? 180.0f : (this.calcRotationPhase(this.rotation, Vars.timeFlow > 0 ? partial : 0.0f) * 360.0F);
|
||||
}
|
||||
|
||||
public int getMoonPhase(int moon) {
|
||||
this.rand.setSeed((this.dimension.getSeed() + moon) ^ (moon << 12));
|
||||
return (int)(this.rotation / this.dimension.getRotationalPeriod() % 8L + 8L + this.rand.zrange(8)) % 8;
|
||||
|
@ -801,10 +603,6 @@ public abstract class World implements IWorldAccess {
|
|||
return MOON_PHASES[this.getMoonPhase(0)];
|
||||
}
|
||||
|
||||
public float getDayPhase(float partial) {
|
||||
return !this.dimension.hasDaylight() || this.dimension.isBaseDestroyed() ? (float)Math.PI : (this.calcRotationPhase(this.rotation, Vars.timeFlow > 0 ? partial : 0.0f) * (float)Math.PI * 2.0F);
|
||||
}
|
||||
|
||||
public BlockPos getPrecipitationHeight(BlockPos pos) {
|
||||
return this.getChunk(pos).getPrecipitation(pos);
|
||||
}
|
||||
|
@ -1348,12 +1146,6 @@ public abstract class World implements IWorldAccess {
|
|||
this.removeTiles.add(tileEntityIn);
|
||||
}
|
||||
|
||||
protected void calculateInitialSkylight() {
|
||||
int light = this.calcSkylightSubtracted(false);
|
||||
if(light != this.subtract)
|
||||
this.subtract = light;
|
||||
}
|
||||
|
||||
protected void calculateInitialWeather() {
|
||||
this.rain = this.weather.hasDownfall() ? 1.0f : 0.0f;
|
||||
this.darkness = this.weather.isDark() ? 1.0f : 0.0f;
|
||||
|
@ -1361,39 +1153,19 @@ public abstract class World implements IWorldAccess {
|
|||
this.temp = this.getBaseTemperature() + this.weather.getTemperature();
|
||||
}
|
||||
|
||||
public Set<ChunkPos> setActivePlayerChunksAndCheckLight(int l) {
|
||||
public Set<ChunkPos> setActiveChunks(int radius) {
|
||||
this.active.clear();
|
||||
// this.profiler.start("buildList");
|
||||
|
||||
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 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 n = 0; n < this.players.size(); ++n) {
|
||||
EntityNPC player = (EntityNPC)this.players.get(n);
|
||||
int x = ExtMath.floord(player.posX / 16.0D);
|
||||
int z = ExtMath.floord(player.posZ / 16.0D);
|
||||
for(int cx = -radius; cx <= radius; cx++) {
|
||||
for(int cz = -radius; cz <= radius; cz++) {
|
||||
this.active.add(new ChunkPos(cx + x, cz + z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this.profiler.end();
|
||||
//
|
||||
// this.profiler.start("playerCheckLight");
|
||||
|
||||
if(!this.players.isEmpty()) {
|
||||
int k1 = this.rand.zrange(this.players.size());
|
||||
EntityNPC entityplayer1 = (EntityNPC)this.players.get(k1);
|
||||
int l1 = ExtMath.floord(entityplayer1.posX) + this.rand.zrange(11) - 5;
|
||||
int i2 = ExtMath.floord(entityplayer1.posY) + this.rand.zrange(11) - 5;
|
||||
int j2 = ExtMath.floord(entityplayer1.posZ) + this.rand.zrange(11) - 5;
|
||||
this.checkBlockLight(new BlockPos(l1, i2, j2));
|
||||
}
|
||||
|
||||
return this.active;
|
||||
|
||||
// this.profiler.end();
|
||||
}
|
||||
|
||||
public float getTempOffset() {
|
||||
|
@ -1435,15 +1207,15 @@ public abstract class World implements IWorldAccess {
|
|||
return this.getTemperatureC(pos) >= 314.0f;
|
||||
}
|
||||
|
||||
public boolean canSnowAt(BlockPos pos, boolean checkLight, boolean allowLayers) {
|
||||
public boolean canSnowAt(BlockPos pos, boolean checkPlace, boolean allowLayers) {
|
||||
if(!this.canFreezeAt(pos)) {
|
||||
return false;
|
||||
}
|
||||
else if(!checkLight) {
|
||||
else if(!checkPlace) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if(pos.getY() >= -MAX_SIZE_Y && pos.getY() < MAX_SIZE_Y && this.getLightFor(pos) < 10) {
|
||||
if(pos.getY() >= -MAX_SIZE_Y && pos.getY() < MAX_SIZE_Y) {
|
||||
Block block = this.getState(pos).getBlock();
|
||||
|
||||
if((block == Blocks.air || (allowLayers && block == Blocks.snow_layer))
|
||||
|
@ -1456,149 +1228,6 @@ public abstract class World implements IWorldAccess {
|
|||
}
|
||||
}
|
||||
|
||||
private int getRawBlockLight(BlockPos pos) {
|
||||
Block block = this.getState(pos).getBlock();
|
||||
int i = block.getLight();
|
||||
int j = block.getLightOpacity();
|
||||
|
||||
if(j >= 15 && block.getLight() > 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(blockpos) - j;
|
||||
|
||||
if(k > i) {
|
||||
i = k;
|
||||
}
|
||||
|
||||
if(i >= 14) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkBlockLight(BlockPos pos) {
|
||||
if(!this.isAreaLoaded(pos, 17, false))
|
||||
return false;
|
||||
int done = 0;
|
||||
int cnt = 0;
|
||||
int light = this.getLightFor(pos);
|
||||
int raw = this.getRawBlockLight(pos);
|
||||
int bx = pos.getX();
|
||||
int by = pos.getY();
|
||||
int bz = pos.getZ();
|
||||
|
||||
if(raw > light) {
|
||||
this.lightUpdate[cnt++] = 133152;
|
||||
}
|
||||
else if(raw < light) {
|
||||
this.lightUpdate[cnt++] = 133152 | light << 18;
|
||||
|
||||
while(done < cnt) {
|
||||
int p = this.lightUpdate[done++];
|
||||
int x = (p & 63) - 32 + bx;
|
||||
int y = (p >> 6 & 63) - 32 + by;
|
||||
int z = (p >> 12 & 63) - 32 + bz;
|
||||
int s = p >> 18 & 15;
|
||||
BlockPos blk = new BlockPos(x, y, z);
|
||||
int l = this.getLightFor(blk);
|
||||
|
||||
if(l == s) {
|
||||
this.setBlockLight(blk, 0);
|
||||
|
||||
if(s > 0) {
|
||||
int dx = ExtMath.absi(x - bx);
|
||||
int dy = ExtMath.absi(y - by);
|
||||
int dz = ExtMath.absi(z - bz);
|
||||
|
||||
if(dx + dy + dz < 17) {
|
||||
BlockPos.MutableBlockPos bpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for(Facing dir : Facing.values()) {
|
||||
int ox = x + dir.getFrontOffsetX();
|
||||
int oy = y + dir.getFrontOffsetY();
|
||||
int oz = z + dir.getFrontOffsetZ();
|
||||
bpos.set(ox, oy, oz);
|
||||
int op = Math.max(1, this.getState(bpos).getBlock().getLightOpacity());
|
||||
l = this.getLightFor(bpos);
|
||||
|
||||
if(l == s - op && cnt < this.lightUpdate.length) {
|
||||
this.lightUpdate[cnt++] = ox - bx + 32 | oy - by + 32 << 6 | oz - bz + 32 << 12 | s - op << 18;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
done = 0;
|
||||
}
|
||||
|
||||
while(done < cnt) {
|
||||
int p = this.lightUpdate[done++];
|
||||
int x = (p & 63) - 32 + bx;
|
||||
int y = (p >> 6 & 63) - 32 + by;
|
||||
int z = (p >> 12 & 63) - 32 + bz;
|
||||
BlockPos blk = new BlockPos(x, y, z);
|
||||
int l = this.getLightFor(blk);
|
||||
int r = this.getRawBlockLight(blk);
|
||||
|
||||
if(r != l) {
|
||||
this.setBlockLight(blk, r);
|
||||
|
||||
if(r > l) {
|
||||
int k6 = Math.abs(x - bx);
|
||||
int l6 = Math.abs(y - by);
|
||||
int i7 = Math.abs(z - bz);
|
||||
boolean flag = cnt < this.lightUpdate.length - 6;
|
||||
|
||||
if(k6 + l6 + i7 < 17 && flag) {
|
||||
if(this.getLightFor(blk.west()) < r) {
|
||||
this.lightUpdate[cnt++] = x - 1 - bx + 32 + (y - by + 32 << 6) + (z - bz + 32 << 12);
|
||||
}
|
||||
|
||||
if(this.getLightFor(blk.east()) < r) {
|
||||
this.lightUpdate[cnt++] = x + 1 - bx + 32 + (y - by + 32 << 6) + (z - bz + 32 << 12);
|
||||
}
|
||||
|
||||
if(this.getLightFor(blk.down()) < r) {
|
||||
this.lightUpdate[cnt++] = x - bx + 32 + (y - 1 - by + 32 << 6) + (z - bz + 32 << 12);
|
||||
}
|
||||
|
||||
if(this.getLightFor(blk.up()) < r) {
|
||||
this.lightUpdate[cnt++] = x - bx + 32 + (y + 1 - by + 32 << 6) + (z - bz + 32 << 12);
|
||||
}
|
||||
|
||||
if(this.getLightFor(blk.north()) < r) {
|
||||
this.lightUpdate[cnt++] = x - bx + 32 + (y - by + 32 << 6) + (z - 1 - bz + 32 << 12);
|
||||
}
|
||||
|
||||
if(this.getLightFor(blk.south()) < r) {
|
||||
this.lightUpdate[cnt++] = x - bx + 32 + (y - by + 32 << 6) + (z + 1 - bz + 32 << 12);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<Entity> getEntitiesWithinAABBExcludingEntity(Entity entityIn, BoundingBox bb) {
|
||||
return this.getEntitiesInAABBexcluding(entityIn, bb, null);
|
||||
}
|
||||
|
@ -1798,9 +1427,6 @@ 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()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1822,11 +1448,6 @@ public abstract class World implements IWorldAccess {
|
|||
double zm = (Math.abs(z) - r) / 16384.0;
|
||||
return ExtMath.clampd(Math.max(Math.max(xm, zm), ym), 0.0, 1.0);
|
||||
}
|
||||
|
||||
@Clientside
|
||||
public static int getSkyLightFor(int y) {
|
||||
return y < 0 ? 0 : (y < 64 ? y / 4 : 15);
|
||||
}
|
||||
|
||||
public double getGravity(double x, double y, double z) {
|
||||
double gravity = this.gravity * (1.0 - this.getSpaceFactor(x, y, z));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue