Update dynamic lights

This commit is contained in:
PeytonPlayz595 2024-06-07 18:08:26 -04:00
parent 9e952ad73a
commit b125383b56
2 changed files with 43 additions and 51 deletions

View File

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

View File

@ -41,14 +41,12 @@ 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_);
} }
} }
}
public static void update(RenderGlobal p_update_0_) { public static void update(RenderGlobal p_update_0_) {
long i = System.currentTimeMillis(); long i = System.currentTimeMillis();
@ -56,7 +54,6 @@ 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) {
@ -66,7 +63,6 @@ public class DynamicLights {
} }
} }
} }
}
private static void updateMapDynamicLights(RenderGlobal p_updateMapDynamicLights_0_) { private static void updateMapDynamicLights(RenderGlobal p_updateMapDynamicLights_0_) {
World world = p_updateMapDynamicLights_0_.getWorld(); World world = p_updateMapDynamicLights_0_.getWorld();
@ -124,7 +120,6 @@ 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();
@ -153,7 +148,6 @@ public class DynamicLights {
} }
} }
} }
}
double d11 = Config.limit(d0, 0.0D, 15.0D); double d11 = Config.limit(d0, 0.0D, 15.0D);
return d11; return d11;
@ -230,7 +224,6 @@ 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();
@ -240,19 +233,14 @@ public class DynamicLights {
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_) {
ItemStack itemstack = p_getItemStack_0_.getDataWatcher().getWatchableObjectItemStack(10); ItemStack itemstack = p_getItemStack_0_.getDataWatcher().getWatchableObjectItemStack(10);