Update dynamic lights
This commit is contained in:
parent
9e952ad73a
commit
b125383b56
|
@ -51,6 +51,10 @@ public class DynamicLight {
|
||||||
double d4 = d1 - this.lastPosZ;
|
double d4 = d1 - this.lastPosZ;
|
||||||
double d5 = 0.1D;
|
double d5 = 0.1D;
|
||||||
|
|
||||||
|
int i = MathHelper.floor_double(d6);
|
||||||
|
int i1 = MathHelper.floor_double(d0);
|
||||||
|
int i2 = MathHelper.floor_double(d1);
|
||||||
|
|
||||||
if (Math.abs(d2) > d5 || Math.abs(d3) > d5 || Math.abs(d4) > d5 || this.lastLightLevel != j) {
|
if (Math.abs(d2) > d5 || Math.abs(d3) > d5 || Math.abs(d4) > d5 || this.lastLightLevel != j) {
|
||||||
this.lastPosX = d6;
|
this.lastPosX = d6;
|
||||||
this.lastPosY = d0;
|
this.lastPosY = d0;
|
||||||
|
@ -60,7 +64,7 @@ public class DynamicLight {
|
||||||
World world = p_update_1_.getWorld();
|
World world = p_update_1_.getWorld();
|
||||||
|
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
this.blockPosMutable.func_181079_c(MathHelper.floor_double(d6), MathHelper.floor_double(d0), MathHelper.floor_double(d1));
|
this.blockPosMutable.func_181079_c(i, i1, i2);
|
||||||
IBlockState iblockstate = world.getBlockState(this.blockPosMutable);
|
IBlockState iblockstate = world.getBlockState(this.blockPosMutable);
|
||||||
Block block = iblockstate.getBlock();
|
Block block = iblockstate.getBlock();
|
||||||
this.underwater = block == Blocks.water;
|
this.underwater = block == Blocks.water;
|
||||||
|
@ -69,9 +73,9 @@ public class DynamicLight {
|
||||||
Set < BlockPos > set = new HashSet();
|
Set < BlockPos > set = new HashSet();
|
||||||
|
|
||||||
if (j > 0) {
|
if (j > 0) {
|
||||||
EnumFacing enumfacing2 = (MathHelper.floor_double(d6) & 15) >= 8 ? EnumFacing.EAST : EnumFacing.WEST;
|
EnumFacing enumfacing2 = (i & 15) >= 8 ? EnumFacing.EAST : EnumFacing.WEST;
|
||||||
EnumFacing enumfacing = (MathHelper.floor_double(d0) & 15) >= 8 ? EnumFacing.UP : EnumFacing.DOWN;
|
EnumFacing enumfacing = (i1 & 15) >= 8 ? EnumFacing.UP : EnumFacing.DOWN;
|
||||||
EnumFacing enumfacing1 = (MathHelper.floor_double(d1) & 15) >= 8 ? EnumFacing.SOUTH : EnumFacing.NORTH;
|
EnumFacing enumfacing1 = (i2 & 15) >= 8 ? EnumFacing.SOUTH : EnumFacing.NORTH;
|
||||||
BlockPos blockpos = new BlockPos(d6, d0, d1);
|
BlockPos blockpos = new BlockPos(d6, d0, d1);
|
||||||
RenderChunk renderchunk = p_update_1_.getRenderChunk(blockpos);
|
RenderChunk renderchunk = p_update_1_.getRenderChunk(blockpos);
|
||||||
RenderChunk renderchunk1 = p_update_1_.getRenderChunk(renderchunk, enumfacing2);
|
RenderChunk renderchunk1 = p_update_1_.getRenderChunk(renderchunk, enumfacing2);
|
||||||
|
|
|
@ -41,12 +41,10 @@ public class DynamicLights {
|
||||||
public static void entityAdded(Entity p_entityAdded_0_, RenderGlobal p_entityAdded_1_) {}
|
public static void entityAdded(Entity p_entityAdded_0_, RenderGlobal p_entityAdded_1_) {}
|
||||||
|
|
||||||
public static void entityRemoved(Entity p_entityRemoved_0_, RenderGlobal p_entityRemoved_1_) {
|
public static void entityRemoved(Entity p_entityRemoved_0_, RenderGlobal p_entityRemoved_1_) {
|
||||||
synchronized(mapDynamicLights) {
|
DynamicLight dynamiclight = (DynamicLight) mapDynamicLights.remove(IntegerCache.func_181756_a(p_entityRemoved_0_.getEntityId()));
|
||||||
DynamicLight dynamiclight = (DynamicLight) mapDynamicLights.remove(IntegerCache.func_181756_a(p_entityRemoved_0_.getEntityId()));
|
|
||||||
|
|
||||||
if (dynamiclight != null) {
|
if (dynamiclight != null) {
|
||||||
dynamiclight.updateLitChunks(p_entityRemoved_1_);
|
dynamiclight.updateLitChunks(p_entityRemoved_1_);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,13 +54,11 @@ public class DynamicLights {
|
||||||
if (i >= timeUpdateMs + 50L) {
|
if (i >= timeUpdateMs + 50L) {
|
||||||
timeUpdateMs = i;
|
timeUpdateMs = i;
|
||||||
|
|
||||||
synchronized(mapDynamicLights) {
|
updateMapDynamicLights(p_update_0_);
|
||||||
updateMapDynamicLights(p_update_0_);
|
|
||||||
|
|
||||||
if (mapDynamicLights.size() > 0) {
|
if (mapDynamicLights.size() > 0) {
|
||||||
for (DynamicLight dynamiclight: mapDynamicLights.values()) {
|
for (DynamicLight dynamiclight: mapDynamicLights.values()) {
|
||||||
dynamiclight.update(p_update_0_);
|
dynamiclight.update(p_update_0_);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,32 +120,30 @@ public class DynamicLights {
|
||||||
public static double getLightLevel(BlockPos p_getLightLevel_0_) {
|
public static double getLightLevel(BlockPos p_getLightLevel_0_) {
|
||||||
double d0 = 0.0D;
|
double d0 = 0.0D;
|
||||||
|
|
||||||
synchronized(mapDynamicLights) {
|
for (DynamicLight dynamiclight: mapDynamicLights.values()) {
|
||||||
for (DynamicLight dynamiclight: mapDynamicLights.values()) {
|
int i = dynamiclight.getLastLightLevel();
|
||||||
int i = dynamiclight.getLastLightLevel();
|
|
||||||
|
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
double d1 = dynamiclight.getLastPosX();
|
double d1 = dynamiclight.getLastPosX();
|
||||||
double d2 = dynamiclight.getLastPosY();
|
double d2 = dynamiclight.getLastPosY();
|
||||||
double d3 = dynamiclight.getLastPosZ();
|
double d3 = dynamiclight.getLastPosZ();
|
||||||
double d4 = (double) p_getLightLevel_0_.getX() - d1;
|
double d4 = (double) p_getLightLevel_0_.getX() - d1;
|
||||||
double d5 = (double) p_getLightLevel_0_.getY() - d2;
|
double d5 = (double) p_getLightLevel_0_.getY() - d2;
|
||||||
double d6 = (double) p_getLightLevel_0_.getZ() - d3;
|
double d6 = (double) p_getLightLevel_0_.getZ() - d3;
|
||||||
double d7 = d4 * d4 + d5 * d5 + d6 * d6;
|
double d7 = d4 * d4 + d5 * d5 + d6 * d6;
|
||||||
|
|
||||||
if (dynamiclight.isUnderwater() && !Config.isClearWater()) {
|
if (dynamiclight.isUnderwater() && !Config.isClearWater()) {
|
||||||
i = Config.limit(i - 2, 0, 15);
|
i = Config.limit(i - 2, 0, 15);
|
||||||
d7 *= 2.0D;
|
d7 *= 2.0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d7 <= 56.25D) {
|
if (d7 <= 56.25D) {
|
||||||
double d8 = Math.sqrt(d7);
|
double d8 = Math.sqrt(d7);
|
||||||
double d9 = 1.0D - d8 / 7.5D;
|
double d9 = 1.0D - d8 / 7.5D;
|
||||||
double d10 = d9 * (double) i;
|
double d10 = d9 * (double) i;
|
||||||
|
|
||||||
if (d10 > d0) {
|
if (d10 > d0) {
|
||||||
d0 = d10;
|
d0 = d10;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,28 +224,22 @@ public class DynamicLights {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeLights(RenderGlobal p_removeLights_0_) {
|
public static void removeLights(RenderGlobal p_removeLights_0_) {
|
||||||
synchronized(mapDynamicLights) {
|
Collection < DynamicLight > collection = mapDynamicLights.values();
|
||||||
Collection < DynamicLight > collection = mapDynamicLights.values();
|
Iterator iterator = collection.iterator();
|
||||||
Iterator iterator = collection.iterator();
|
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
DynamicLight dynamiclight = (DynamicLight) iterator.next();
|
DynamicLight dynamiclight = (DynamicLight) iterator.next();
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
dynamiclight.updateLitChunks(p_removeLights_0_);
|
dynamiclight.updateLitChunks(p_removeLights_0_);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clear() {
|
public static void clear() {
|
||||||
synchronized(mapDynamicLights) {
|
mapDynamicLights.clear();
|
||||||
mapDynamicLights.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getCount() {
|
public static int getCount() {
|
||||||
synchronized(mapDynamicLights) {
|
return mapDynamicLights.size();
|
||||||
return mapDynamicLights.size();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack getItemStack(EntityItem p_getItemStack_0_) {
|
public static ItemStack getItemStack(EntityItem p_getItemStack_0_) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user