make light clientside
This commit is contained in:
parent
e3e5fbd7fd
commit
16d20fb31d
54 changed files with 556 additions and 1316 deletions
|
@ -348,7 +348,6 @@ public class Client implements IThreadListener {
|
|||
super(dim, true);
|
||||
this.orbit = dim.getOrbit();
|
||||
this.rotation = dim.getRotation();
|
||||
this.calculateInitialSkylight();
|
||||
this.calculateInitialWeather();
|
||||
this.updatePhysics();
|
||||
}
|
||||
|
@ -424,6 +423,14 @@ public class Client implements IThreadListener {
|
|||
public void setLastLightning(int last, int color) {
|
||||
Client.this.renderer.setLastLightning(last, color);
|
||||
}
|
||||
|
||||
public void checkBlockLight(BlockPos pos) {
|
||||
Client.this.renderer.checkBlockLight(pos);
|
||||
}
|
||||
|
||||
public int getCombinedLight(BlockPos pos, int lightValue) {
|
||||
return Client.this.renderer.getCombinedLight(pos, lightValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static final String VERSION = Version.NAME + " Client " + Util.VERSION;
|
||||
|
@ -590,6 +597,10 @@ public class Client implements IThreadListener {
|
|||
public int renderDistance = 8;
|
||||
@Variable(name = "chunk_build_time", category = CVarCategory.RENDER, min = 1, max = 100, display = "Zeit für Chunk-Bau", unit = "ms")
|
||||
public int maxBuildTime = 8;
|
||||
@Variable(name = "chunk_light_updates", category = CVarCategory.RENDER, min = 100, max = 10000, display = "Licht-Updates / Tick")
|
||||
private int lightUpdates = 2048;
|
||||
@Variable(name = "chunk_light_range", category = CVarCategory.RENDER, min = 5, max = 1024, display = "Radius Licht-Updates")
|
||||
private int lightRange = 32;
|
||||
@Variable(name = "gl_fov", category = CVarCategory.RENDER, min = 1.0f, max = 179.0f, display = "Sichtfeld (FOV)", unit = "°", precision = 1)
|
||||
public float fov = 70.0f;
|
||||
@Variable(name = "gl_wireframe", category = CVarCategory.RENDER, display = "Gitter-Render-Modus")
|
||||
|
@ -2042,11 +2053,11 @@ public class Client implements IThreadListener {
|
|||
String.format("Biom: %.2f K, N: %.2f K, D: %s (%s)", chunk.getTemperature(pos), chunk.getOffset(pos),
|
||||
Color.stripCodes(this.world.dimension.getDisplay()),
|
||||
this.dimensionName) + "\n" +
|
||||
"Licht: " + chunk.getLightSub(pos, 0) + " (" + (this.world.dimension.hasSkyLight() ? + World.getSkyLightFor(pos.getY()) + " Himmel, " : "")
|
||||
"Licht: " + chunk.getLightSub(pos, 0) + " (" + (this.world.dimension.hasSkyLight() ? + Renderer.getSkyLightFor(pos.getY()) + " Himmel, " : "")
|
||||
+ chunk.getLight(pos) + " Blöcke, " + String.format(
|
||||
"%.1f", this.renderer.getSunBrightness(1.0f) * 15.0f) + " Welt), A: "
|
||||
+ String.format("%.1f ° (%.1f, %.1f)", this.world.getCelestialAngle(1.0f), !this.world.dimension.hasDaylight() ? 0.0f : ExtMath.cos((-90.0f + this.world.getCelestialAngle(1.0f)) / 180.0f * (float)Math.PI),
|
||||
!this.world.dimension.hasDaylight() ? -1.0f : ExtMath.sin((-90.0f + this.world.getCelestialAngle(1.0f)) / 180.0f * (float)Math.PI)) + "\n" +
|
||||
+ String.format("%.1f ° (%.1f, %.1f)", this.renderer.getCelestialAngle(1.0f), !this.world.dimension.hasDaylight() ? 0.0f : ExtMath.cos((-90.0f + this.renderer.getCelestialAngle(1.0f)) / 180.0f * (float)Math.PI),
|
||||
!this.world.dimension.hasDaylight() ? -1.0f : ExtMath.sin((-90.0f + this.renderer.getCelestialAngle(1.0f)) / 180.0f * (float)Math.PI)) + "\n" +
|
||||
String.format("Zeit: %s" + (this.world.dimension.hasRotation() ? ", R %d / %d T" : "") + (this.world.dimension.hasOrbit() ? ", U %d / %d T" : ""),
|
||||
this.world.formatEpochSimple(),
|
||||
this.world.getRotation(),
|
||||
|
@ -3666,16 +3677,25 @@ public class Client implements IThreadListener {
|
|||
long time = System.currentTimeMillis();
|
||||
for (ChunkClient chunk : this.chunkListing)
|
||||
{
|
||||
chunk.update(System.currentTimeMillis() - time > 5L);
|
||||
chunk.spawnTiles();
|
||||
}
|
||||
if (System.currentTimeMillis() - time > 100L)
|
||||
{
|
||||
Log.TICK.warn("Render-Chunk-Tick dauerte " + (System.currentTimeMillis() - time) + " ms");
|
||||
}
|
||||
|
||||
Set<ChunkPos> active = this.world.setActivePlayerChunksAndCheckLight(this.renderDistance);
|
||||
this.previousActive.retainAll(active);
|
||||
|
||||
if(this.player != null) {
|
||||
int radius = Math.min(this.renderDistance * 16, this.lightRange);
|
||||
for(int n = 0; n < this.lightUpdates; n++) {
|
||||
int x = ExtMath.floord(this.player.posX) + this.world.rand.range(-radius, radius);
|
||||
int y = ExtMath.floord(this.player.posY) + this.world.rand.range(-radius, radius);
|
||||
int z = ExtMath.floord(this.player.posZ) + this.world.rand.range(-radius, radius);
|
||||
this.world.checkBlockLight(new BlockPos(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
Set<ChunkPos> active = this.world.setActiveChunks(this.renderDistance);
|
||||
this.previousActive.retainAll(active);
|
||||
if (this.previousActive.size() == active.size())
|
||||
{
|
||||
this.previousActive.clear();
|
||||
|
|
|
@ -92,6 +92,10 @@ public class GuiDisplay extends GuiOptions {
|
|||
|
||||
this.distanceSlider = this.addSelector("chunk_view_distance", 0, 160, 240, 0);
|
||||
this.addSelector("chunk_build_time", 242, 160, 240, 0);
|
||||
|
||||
this.addSelector("chunk_light_updates", 0, 180, 240, 0);
|
||||
this.addSelector("chunk_light_range", 242, 180, 240, 0);
|
||||
|
||||
super.init(width, height);
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ public class RegionRenderCache implements IWorldAccess
|
|||
|
||||
public int getLight(BlockPos pos, int lightValue)
|
||||
{
|
||||
int i = this.sky ? World.getSkyLightFor(pos.getY()) : 0;
|
||||
int i = this.sky ? Renderer.getSkyLightFor(pos.getY()) : 0;
|
||||
int j = this.getBlockLightExt(pos);
|
||||
|
||||
if (j < lightValue)
|
||||
|
|
|
@ -61,16 +61,19 @@ import common.sound.Sound;
|
|||
import common.tileentity.TileEntity;
|
||||
import common.util.BlockPos;
|
||||
import common.util.BoundingBox;
|
||||
import common.util.Clientside;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Facing;
|
||||
import common.util.HitPosition;
|
||||
import common.util.InheritanceMultiMap;
|
||||
import common.util.Pair;
|
||||
import common.util.HitPosition.ObjectType;
|
||||
import common.vars.Vars;
|
||||
import common.util.ParticleType;
|
||||
import common.util.Vec3;
|
||||
import common.util.Vec3i;
|
||||
import common.util.Vector3f;
|
||||
import common.world.Chunk;
|
||||
import common.world.IBlockAccess;
|
||||
import common.world.IWorldAccess;
|
||||
import common.world.State;
|
||||
|
@ -104,6 +107,7 @@ public class Renderer {
|
|||
private static final float FOG_DISTANCE = 0.4f;
|
||||
private static final float SQRT_2 = ExtMath.sqrtf(2.0F);
|
||||
private static final float[] SUN_COLOR = new float[4];
|
||||
private 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};
|
||||
|
||||
private final Client gm;
|
||||
private final Random rng = new Random();
|
||||
|
@ -188,6 +192,8 @@ public class Renderer {
|
|||
private float blockColorRed;
|
||||
private float blockColorGreen;
|
||||
private float blockColorBlue;
|
||||
private int subtract;
|
||||
private final int[] lightUpdate = new int[32768];
|
||||
|
||||
public Renderer(Client gm, ModelManager manager)
|
||||
{
|
||||
|
@ -268,7 +274,7 @@ public class Renderer {
|
|||
this.gm.setRenderViewEntity(this.gm.player);
|
||||
}
|
||||
|
||||
float light = this.gm.world.getLightBrightness(new BlockPos(this.gm.getRenderViewEntity()));
|
||||
float light = this.getLightBrightness(new BlockPos(this.gm.getRenderViewEntity()));
|
||||
float dist = (float)this.gm.renderDistance / 32.0F;
|
||||
float shift = light * (1.0F - dist) + dist;
|
||||
this.fogMult += (shift - this.fogMult) * 0.1F;
|
||||
|
@ -853,7 +859,7 @@ public class Renderer {
|
|||
}
|
||||
|
||||
public float getSunBrightness(float partial) {
|
||||
float f = this.gm.world.getDayPhase(partial);
|
||||
float f = this.getDayPhase(partial);
|
||||
float f1 = 1.0F - (ExtMath.cos(f) * 2.0F + 0.2F);
|
||||
f1 = ExtMath.clampf(f1, 0.0F, 1.0F);
|
||||
f1 = 1.0F - f1;
|
||||
|
@ -871,7 +877,7 @@ public class Renderer {
|
|||
else
|
||||
vec = new Vec3(this.gm.world.dimension.getSkyColor());
|
||||
if(this.gm.world.dimension.hasDaylight()) {
|
||||
float mult = ExtMath.clampf(ExtMath.cos(this.gm.world.getDayPhase(partial)) * 2.0F + 0.5F, 0.0F, 1.0F);
|
||||
float mult = ExtMath.clampf(ExtMath.cos(this.getDayPhase(partial)) * 2.0F + 0.5F, 0.0F, 1.0F);
|
||||
vec = new Vec3(vec.xCoord * mult, vec.yCoord * mult, vec.zCoord * mult);
|
||||
}
|
||||
float r = (float)vec.xCoord;
|
||||
|
@ -934,7 +940,7 @@ public class Renderer {
|
|||
}
|
||||
|
||||
if(this.gm.world.dimension.hasDaylight()) {
|
||||
float sun = ExtMath.clampf(ExtMath.cos(this.gm.world.getDayPhase(partialTicks)) * 2.0F + 0.5F,
|
||||
float sun = ExtMath.clampf(ExtMath.cos(this.getDayPhase(partialTicks)) * 2.0F + 0.5F,
|
||||
0.0F, 1.0F);
|
||||
r = r * (sun * 0.9F + 0.1F);
|
||||
g = g * (sun * 0.9F + 0.1F);
|
||||
|
@ -961,14 +967,14 @@ public class Renderer {
|
|||
}
|
||||
|
||||
private float getStarBrightness(float partialTicks) {
|
||||
float f = this.gm.world.getDayPhase(partialTicks);
|
||||
float f = this.getDayPhase(partialTicks);
|
||||
float f1 = 1.0F - (ExtMath.cos(f) * 2.0F + 0.25F);
|
||||
f1 = ExtMath.clampf(f1, 0.0F, 1.0F);
|
||||
return Math.max(f1 * f1 * this.gm.world.dimension.getStarBrightness(), this.getSpaceFactor());
|
||||
}
|
||||
|
||||
private float getDeepStarBrightness(float partialTicks) {
|
||||
float f = this.gm.world.getDayPhase(partialTicks);
|
||||
float f = this.getDayPhase(partialTicks);
|
||||
float f1 = 1.0F - (ExtMath.cos(f) * 2.0F + 0.25F);
|
||||
f1 = ExtMath.clampf(f1, 0.0F, 1.0F);
|
||||
return Math.max(f1 * f1 * this.gm.world.dimension.getDeepStarBrightness(), this.getSpaceFactor());
|
||||
|
@ -994,8 +1000,8 @@ public class Renderer {
|
|||
|
||||
for (int n = 0; n < 256; ++n)
|
||||
{
|
||||
float rsky = World.BRIGHTNESS[n / 16];
|
||||
float rblock = World.BRIGHTNESS[n % 16];
|
||||
float rsky = BRIGHTNESS[n / 16];
|
||||
float rblock = BRIGHTNESS[n % 16];
|
||||
float sky = rsky * msun;
|
||||
float block = rblock * (this.torchFlickerX * 0.1F + 1.5F);
|
||||
|
||||
|
@ -1550,7 +1556,7 @@ public class Renderer {
|
|||
}
|
||||
|
||||
if(world.dimension.hasDaylight()) {
|
||||
float sun = ExtMath.clampf(ExtMath.cos(world.getDayPhase(partial)) * 2.0F + 0.5F, 0.0F, 1.0F);
|
||||
float sun = ExtMath.clampf(ExtMath.cos(this.getDayPhase(partial)) * 2.0F + 0.5F, 0.0F, 1.0F);
|
||||
this.fogColorRed = this.fogColorRed * (sun * 0.94F + 0.06F);
|
||||
this.fogColorGreen = this.fogColorGreen * (sun * 0.94F + 0.06F);
|
||||
this.fogColorBlue = this.fogColorBlue * (sun * 0.91F + 0.09F);
|
||||
|
@ -1566,11 +1572,11 @@ public class Renderer {
|
|||
if (this.gm.renderDistance >= 4 && world.dimension.hasDaylight() && !world.dimension.isBaseDestroyed())
|
||||
{
|
||||
double neg = -1.0D;
|
||||
Vec3 pos = ExtMath.sin(world.getDayPhase(partial)) > 0.0F ? new Vec3(neg, 0.0D, 0.0D) : new Vec3(1.0D, 0.0D, 0.0D);
|
||||
Vec3 pos = ExtMath.sin(this.getDayPhase(partial)) > 0.0F ? new Vec3(neg, 0.0D, 0.0D) : new Vec3(1.0D, 0.0D, 0.0D);
|
||||
float shift = (float)entity.getLook(partial).dotProduct(pos);
|
||||
if (shift > 0.0F)
|
||||
{
|
||||
float[] sun = calcSunriseSunsetColors(world.getDayPhase(partial), partial);
|
||||
float[] sun = calcSunriseSunsetColors(this.getDayPhase(partial), partial);
|
||||
if (sun != null)
|
||||
{
|
||||
shift = shift * sun[3];
|
||||
|
@ -2035,6 +2041,7 @@ public class Renderer {
|
|||
|
||||
if (worldClientIn != null)
|
||||
{
|
||||
this.calculateInitialSkylight();
|
||||
// worldClientIn.setWorldAccess(this);
|
||||
this.loadRenderers();
|
||||
}
|
||||
|
@ -2733,14 +2740,14 @@ public class Renderer {
|
|||
ItemRenderer.disableStandardItemLighting();
|
||||
|
||||
float[] afloat = this.theWorld.dimension.hasDaylight() && !this.theWorld.dimension.isBaseDestroyed() ?
|
||||
calcSunriseSunsetColors(this.theWorld.getDayPhase(partialTicks), partialTicks) : null;
|
||||
calcSunriseSunsetColors(this.getDayPhase(partialTicks), partialTicks) : null;
|
||||
if (afloat != null)
|
||||
{
|
||||
GlState.disableTexture2D();
|
||||
GlState.shadeModel(GL46.GL_SMOOTH);
|
||||
GL46.glPushMatrix();
|
||||
GL46.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL46.glRotatef(ExtMath.sin(this.theWorld.getDayPhase(partialTicks)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F);
|
||||
GL46.glRotatef(ExtMath.sin(this.getDayPhase(partialTicks)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F);
|
||||
GL46.glRotatef(90.0F, 0.0F, 0.0F, 1.0F);
|
||||
float f6 = afloat[0];
|
||||
float f7 = afloat[1];
|
||||
|
@ -2778,7 +2785,7 @@ public class Renderer {
|
|||
GL46.glPushMatrix();
|
||||
float f16 = 1.0F - Math.max(this.theWorld.getRainStrength(), this.theWorld.getFogStrength());
|
||||
GL46.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL46.glRotatef(this.theWorld.getCelestialAngle(partialTicks), 1.0F, 0.0F, 0.0F);
|
||||
GL46.glRotatef(this.getCelestialAngle(partialTicks), 1.0F, 0.0F, 0.0F);
|
||||
if(this.gm.world.dimension.getType() == DimType.PLANET || this.gm.world.dimension.getType() == DimType.MOON) {
|
||||
float size = 30.0F;
|
||||
int color = this.gm.world.dimension.getSunColor();
|
||||
|
@ -3242,10 +3249,11 @@ public class Renderer {
|
|||
}
|
||||
}
|
||||
|
||||
public void renderBlockEntity(State state, float brightness)
|
||||
public void renderBlockEntity(State state, BlockPos brightPos)
|
||||
{
|
||||
if (state.getBlock() != Blocks.air && !state.getBlock().getMaterial().isLiquid())
|
||||
{
|
||||
float brightness = brightPos == null ? 1.0f : this.getLightBrightness(brightPos);
|
||||
IBakedModel model = this.manager.getModelForState(state);
|
||||
Block block = state.getBlock();
|
||||
GL46.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
|
||||
|
@ -3915,4 +3923,307 @@ public class Renderer {
|
|||
|
||||
return n == 4 ? 1.0f : (s + a == 4 && a > 1 ? 0.0f : 1.0F - f / (float)i);
|
||||
}
|
||||
|
||||
private int getLightFor(BlockPos pos) {
|
||||
if(pos.getY() < -World.MAX_SIZE_Y) {
|
||||
pos = new BlockPos(pos.getX(), -World.MAX_SIZE_Y, pos.getZ());
|
||||
}
|
||||
|
||||
if(!World.isValid(pos)) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
ChunkClient chunk = this.gm.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
|
||||
return chunk.getLight(pos);
|
||||
}
|
||||
}
|
||||
|
||||
private int getBlockLightSum(BlockPos pos) {
|
||||
if(pos.getY() < -World.MAX_SIZE_Y) {
|
||||
pos = new BlockPos(pos.getX(), -World.MAX_SIZE_Y, pos.getZ());
|
||||
}
|
||||
|
||||
if(!World.isValid(pos)) {
|
||||
return 0;
|
||||
}
|
||||
else if(this.gm.world.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 {
|
||||
ChunkClient chunk = this.gm.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
|
||||
return chunk.getLight(pos);
|
||||
}
|
||||
}
|
||||
|
||||
public int getCombinedLight(BlockPos pos, int lightValue) {
|
||||
int i = this.gm.world.dimension.hasSkyLight() ? getSkyLightFor(pos.getY()) : 0;
|
||||
int j = this.getBlockLightSum(pos);
|
||||
|
||||
if(j < lightValue) {
|
||||
j = lightValue;
|
||||
}
|
||||
|
||||
return i << 20 | j << 4;
|
||||
}
|
||||
|
||||
private int getLight(BlockPos pos, boolean checkNeighbors) {
|
||||
if(pos.getX() >= -World.MAX_SIZE && pos.getZ() >= -World.MAX_SIZE && pos.getX() < World.MAX_SIZE && pos.getZ() < World.MAX_SIZE) {
|
||||
if(checkNeighbors && this.gm.world.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() < -World.MAX_SIZE_Y) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
if(pos.getY() >= World.MAX_SIZE_Y) {
|
||||
pos = new BlockPos(pos.getX(), World.MAX_SIZE_Y - 1, pos.getZ());
|
||||
}
|
||||
|
||||
ChunkClient chunk = this.gm.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
|
||||
return chunk.getLightSub(pos, this.subtract);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 15;
|
||||
}
|
||||
}
|
||||
|
||||
public float getLightBrightness(BlockPos pos) {
|
||||
return Math.max(BRIGHTNESS[this.getLight(pos, true)], (float)this.gm.world.dimension.getBrightness() / 15.0f);
|
||||
}
|
||||
|
||||
private int getRawBlockLight(BlockPos pos) {
|
||||
Block block = this.gm.world.getState(pos).getBlock();
|
||||
int light = block.getLight();
|
||||
int opacity = block.getLightOpacity();
|
||||
|
||||
if(opacity >= 15 && block.getLight() > 0) {
|
||||
opacity = 1;
|
||||
}
|
||||
|
||||
if(opacity < 1) {
|
||||
opacity = 1;
|
||||
}
|
||||
|
||||
if(opacity >= 15) {
|
||||
return 0;
|
||||
}
|
||||
else if(light >= 14) {
|
||||
return light;
|
||||
}
|
||||
else {
|
||||
for(Facing side : Facing.values()) {
|
||||
BlockPos bpos = pos.offset(side);
|
||||
int blight = this.getLightFor(bpos) - opacity;
|
||||
|
||||
if(blight > light) {
|
||||
light = blight;
|
||||
}
|
||||
|
||||
if(light >= 14) {
|
||||
return light;
|
||||
}
|
||||
}
|
||||
|
||||
return light;
|
||||
}
|
||||
}
|
||||
|
||||
private void setBlockLight(BlockPos pos, int lightValue) {
|
||||
if(World.isValid(pos)) {
|
||||
ChunkClient chunk = this.gm.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
|
||||
chunk.setLight(pos, lightValue);
|
||||
this.markUpdate(pos.getX() - 1, pos.getY() - 1, pos.getZ() - 1, pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkBlockLight(BlockPos pos) {
|
||||
if(!this.gm.world.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.theWorld.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;
|
||||
}
|
||||
|
||||
private void calculateInitialSkylight() {
|
||||
float f = !this.gm.world.dimension.hasDaylight() ? 0.5f : this.calcRotationPhase(this.gm.world.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.gm.world.getRainStrength() * 5.0F) / 16.0D));
|
||||
// f1 = (float)((double)f1 * (1.0D - (double)(this.gm.world.getDarkness() * 5.0F) / 16.0D));
|
||||
// f1 = 1.0F - f1;
|
||||
this.subtract = (int)(f1 * 11.0F);
|
||||
}
|
||||
|
||||
public static int getSkyLightFor(int y) {
|
||||
return y < 0 ? 0 : (y < 64 ? y / 4 : 15);
|
||||
}
|
||||
|
||||
private float calcRotationPhase(long worldTime, float partial) {
|
||||
int i = (int)(worldTime % this.gm.world.dimension.getRotationalPeriod());
|
||||
float f = ((float)i + partial) / (float)this.gm.world.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 float getCelestialAngle(float partial) {
|
||||
return !this.gm.world.dimension.hasRotation() ? 180.0f : (this.calcRotationPhase(this.gm.world.getRotation(), Vars.timeFlow > 0 ? partial : 0.0f) * 360.0F);
|
||||
}
|
||||
|
||||
private float getDayPhase(float partial) {
|
||||
return !this.gm.world.dimension.hasDaylight() || this.gm.world.dimension.isBaseDestroyed() ? (float)Math.PI : (this.calcRotationPhase(this.gm.world.getRotation(), Vars.timeFlow > 0 ? partial : 0.0f) * (float)Math.PI * 2.0F);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public enum Shader {
|
|||
context.matrix("projection", MatrixState.getProjection());
|
||||
context.vec("time", (float)Util.ftime());
|
||||
|
||||
float angle = -90.0f + Client.CLIENT.world.getCelestialAngle(Client.CLIENT.getTickFraction());
|
||||
float angle = -90.0f + Client.CLIENT.renderer.getCelestialAngle(Client.CLIENT.getTickFraction());
|
||||
|
||||
float sunX = !Client.CLIENT.world.dimension.hasDaylight() ? 0.0f : ExtMath.cos(angle / 180.0f * (float)Math.PI);
|
||||
float sunY = !Client.CLIENT.world.dimension.hasDaylight() ? -1.0f : ExtMath.sin(angle / 180.0f * (float)Math.PI);
|
||||
|
|
|
@ -2,7 +2,6 @@ package client.renderer.entity;
|
|||
|
||||
import client.renderer.Frustum;
|
||||
import common.entity.Entity;
|
||||
import common.util.BlockPos;
|
||||
import common.util.BoundingBox;
|
||||
|
||||
public abstract class Render<T extends Entity>
|
||||
|
@ -54,9 +53,4 @@ public abstract class Render<T extends Entity>
|
|||
{
|
||||
return this.manager;
|
||||
}
|
||||
|
||||
protected static float getBrightness(Entity entity) {
|
||||
BlockPos pos = new BlockPos(entity.posX, entity.posY + (double)entity.getEyeHeight(), entity.posZ);
|
||||
return entity.worldObj.isBlockLoaded(pos) ? entity.worldObj.getLightBrightness(pos) : 0.0F;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.lwjgl.opengl.GL46;
|
|||
import client.Client;
|
||||
import client.renderer.texture.TextureMap;
|
||||
import common.entity.Entity;
|
||||
import common.util.BlockPos;
|
||||
import common.world.State;
|
||||
|
||||
|
||||
|
@ -24,7 +25,7 @@ public class RenderBlockEntity extends Render<Entity>
|
|||
GL46.glTranslatef((float)x, (float)y + 0.5F, (float)z);
|
||||
this.bindEntityTexture(entity);
|
||||
GL46.glTranslatef(-0.5F, -0.5F, 0.5F);
|
||||
Client.CLIENT.renderer.renderBlockEntity(this.state, getBrightness(entity));
|
||||
Client.CLIENT.renderer.renderBlockEntity(this.state, new BlockPos(entity.posX, entity.posY + (double)entity.getEyeHeight(), entity.posZ));
|
||||
GL46.glTranslatef(0.0F, 0.0F, 1.0F);
|
||||
GL46.glPopMatrix();
|
||||
super.doRender(entity, x, y, z, partialTicks);
|
||||
|
|
|
@ -29,7 +29,7 @@ public class RenderFallingBlock extends Render<EntityFalling> {
|
|||
GL46.glTranslatef((float)x, (float)y + 0.5F, (float)z);
|
||||
this.bindEntityTexture(entity);
|
||||
GL46.glTranslatef(-0.5F, -0.5F, 0.5F);
|
||||
Client.CLIENT.renderer.renderBlockEntity(state, getBrightness(entity));
|
||||
Client.CLIENT.renderer.renderBlockEntity(state, new BlockPos(entity.posX, entity.posY + (double)entity.getEyeHeight(), entity.posZ));
|
||||
GL46.glTranslatef(0.0F, 0.0F, 1.0F);
|
||||
GL46.glPopMatrix();
|
||||
super.doRender(entity, x, y, z, partialTicks);
|
||||
|
|
|
@ -9,6 +9,7 @@ import client.renderer.model.ModelMinecart;
|
|||
import client.renderer.texture.TextureMap;
|
||||
import common.entity.item.EntityCart;
|
||||
import common.init.Blocks;
|
||||
import common.util.BlockPos;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Vec3;
|
||||
import common.world.State;
|
||||
|
@ -124,7 +125,7 @@ public class RenderMinecart<T extends EntityCart> extends Render<T>
|
|||
protected void func_180560_a(T minecart, float partialTicks, State state)
|
||||
{
|
||||
GL46.glPushMatrix();
|
||||
Client.CLIENT.renderer.renderBlockEntity(state, getBrightness(minecart));
|
||||
Client.CLIENT.renderer.renderBlockEntity(state, new BlockPos(minecart.posX, minecart.posY + (double)minecart.getEyeHeight(), minecart.posZ));
|
||||
GL46.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class RenderTntMinecart extends RenderMinecart<EntityTntCart>
|
|||
GlState.blendFunc(GL46.GL_SRC_ALPHA, GL46.GL_DST_ALPHA);
|
||||
GlState.color(1.0F, 1.0F, 1.0F, (1.0F - ((float)i - partialTicks + 1.0F) / 100.0F) * 0.8F);
|
||||
GL46.glPushMatrix();
|
||||
Client.CLIENT.renderer.renderBlockEntity(Blocks.tnt.getState(), 1.0F);
|
||||
Client.CLIENT.renderer.renderBlockEntity(Blocks.tnt.getState(), null);
|
||||
GL46.glPopMatrix();
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlState.disableBlend();
|
||||
|
|
|
@ -9,6 +9,7 @@ import client.renderer.texture.TextureMap;
|
|||
import common.block.Block;
|
||||
import common.entity.item.EntityTnt;
|
||||
import common.init.BlockRegistry;
|
||||
import common.util.BlockPos;
|
||||
import common.util.ExtMath;
|
||||
|
||||
|
||||
|
@ -39,7 +40,7 @@ public class RenderTntPrimed extends Render<EntityTnt>
|
|||
this.bindEntityTexture(entity);
|
||||
GL46.glTranslatef(-0.5F, -0.5F, 0.5F);
|
||||
Block tnt = BlockRegistry.byName("tnt" + (entity.explosionSize <= 0 || entity.explosionSize >= 8 ? "" : "_" + entity.explosionSize));
|
||||
renderer.renderBlockEntity(tnt.getState(), getBrightness(entity));
|
||||
renderer.renderBlockEntity(tnt.getState(), new BlockPos(entity.posX, entity.posY + (double)entity.getEyeHeight(), entity.posZ));
|
||||
GL46.glTranslatef(0.0F, 0.0F, 1.0F);
|
||||
|
||||
if (entity.fuse / 5 % 2 == 0)
|
||||
|
@ -51,7 +52,7 @@ public class RenderTntPrimed extends Render<EntityTnt>
|
|||
GlState.color(1.0F, 1.0F, 1.0F, f2);
|
||||
GlState.doPolygonOffset(-3.0F, -3.0F);
|
||||
GlState.enablePolygonOffset();
|
||||
renderer.renderBlockEntity(tnt.getState(), 1.0F);
|
||||
renderer.renderBlockEntity(tnt.getState(), null);
|
||||
GlState.doPolygonOffset(0.0F, 0.0F);
|
||||
GlState.disablePolygonOffset();
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
package client.world;
|
||||
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import client.renderer.Renderer;
|
||||
import common.block.Block;
|
||||
import common.block.ITileEntityProvider;
|
||||
import common.init.Blocks;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.util.BlockPos;
|
||||
import common.util.NibbleArray;
|
||||
import common.world.BlockArray;
|
||||
import common.world.Chunk;
|
||||
import common.world.World;
|
||||
|
||||
public class ChunkClient extends Chunk {
|
||||
private final ConcurrentLinkedQueue<BlockPos> tileQueue = new ConcurrentLinkedQueue<BlockPos>();
|
||||
private final float[] temperatures = new float[256];
|
||||
private final float[] offsets = new float[256];
|
||||
|
||||
|
@ -48,8 +52,6 @@ public class ChunkClient extends Chunk {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.modified = true;
|
||||
}
|
||||
|
||||
public boolean isEmpty(int bottom, int top) {
|
||||
|
@ -87,11 +89,8 @@ public class ChunkClient extends Chunk {
|
|||
|
||||
for(int cy : extend) {
|
||||
BlockArray arr = this.getArray(cy);
|
||||
if(arr != null) {
|
||||
NibbleArray light = arr.getBlocklight();
|
||||
System.arraycopy(data, pos, light.getData(), 0, light.getData().length);
|
||||
pos += light.getData().length;
|
||||
}
|
||||
if(arr != null)
|
||||
arr.clearLight();
|
||||
}
|
||||
|
||||
if(biomes) {
|
||||
|
@ -110,7 +109,6 @@ public class ChunkClient extends Chunk {
|
|||
}
|
||||
}
|
||||
|
||||
this.populated = true;
|
||||
this.genHeights();
|
||||
|
||||
for(TileEntity tile : this.tiles.values()) {
|
||||
|
@ -137,4 +135,71 @@ public class ChunkClient extends Chunk {
|
|||
int z = pos.getZ() & 15;
|
||||
return this.offsets[z << 4 | x];
|
||||
}
|
||||
|
||||
public void spawnTiles() {
|
||||
while(!this.tileQueue.isEmpty()) {
|
||||
BlockPos pos = 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 TileEntity getTileEntity(BlockPos pos, TileEntity.CreateMode type) {
|
||||
TileEntity tile = this.tiles.get(pos);
|
||||
|
||||
if(tile == null) {
|
||||
if(type == TileEntity.CreateMode.IMMEDIATE) {
|
||||
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);
|
||||
return null;
|
||||
}
|
||||
|
||||
return tile;
|
||||
}
|
||||
|
||||
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.genHeightMap();
|
||||
}
|
||||
|
||||
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() ? Renderer.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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,10 +89,6 @@ public class ChunkEmpty extends ChunkClient {
|
|||
public void removeEntity(Entity entity) {
|
||||
}
|
||||
|
||||
public boolean canSeeSky(BlockPos pos) {
|
||||
return pos.getY() > this.liquidY;
|
||||
}
|
||||
|
||||
public TileEntity getTileEntity(BlockPos pos, TileEntity.CreateMode type) {
|
||||
return null;
|
||||
}
|
||||
|
@ -133,16 +129,12 @@ public class ChunkEmpty extends ChunkClient {
|
|||
return new BlockPos(pos.getX(), this.liquidY + 1, pos.getZ());
|
||||
}
|
||||
|
||||
public void update(boolean noGaps) {
|
||||
public void spawnTiles() {
|
||||
}
|
||||
|
||||
public void onChunkUnload() {
|
||||
}
|
||||
|
||||
public boolean isPopulated() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setData(byte[] data, int[] extend, boolean biomes) {
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue