You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
you only store world capability data, no data per chunk
WorldRadiation
sourceMap <long, SourceTable> - stores the data
long represents BlockPos, and SourceTable stores all sources for that pos
update() method iterates map and calls update for each RadSource
same time we need to keep updated map with calculated data for faster simulation of radiation at any coordinates, will use that to get exposure for livingentities
calculatedMap <long or BlockPos, int radiation>
SourceTable
map or list of RadSources
RadSource
sourceID - (int) will use it to fallback radiation source backend (object) from our registry
timestamp - (int) last updated time
lifetime - int how long this source exists
radiation - digital value of radiation
update() - updates radiation value by current timestamp
RadSourceBackend
int[] stages - contains vector values how source radiation changes during time
during update we split decay_time by amount of stages and apply stage value for radiation change
so for any source we can define any behavior
for example int[]{4, 2, 0, -1, -4}
means it will increase radiation faster at the beginning of decay_time, then it will slowdown and after that will decrease radiation
int initial_radioactivity
int decay_time
public class BlockPosDistanceCalculator {
public static double distanceSquared(BlockPos pos1, BlockPos pos2) {
double dx = pos1.getX() - pos2.getX();
double dy = pos1.getY() - pos2.getY();
double dz = pos1.getZ() - pos2.getZ();
return dx * dx + dy * dy + dz * dz;
}
public static void main(String[] args) {
BlockPos pos1 = new BlockPos(1, 2, 3);
BlockPos pos2 = new BlockPos(4, 5, 6);
double distanceSq = distanceSquared(pos1, pos2);
System.out.println("Squared distance between pos1 and pos2: " + distanceSq);
// If you need the actual distance, you can take the square root of the squared distance.
double distance = Math.sqrt(distanceSq);
System.out.println("Distance between pos1 and pos2: " + distance);
}
}
cache closest sources by entity pos. so if player stays in one place, algorithm won't have to iterate all know sources each time
and also we don't need to simulate that every tick, as we have timestamps we can simulate every second or whatever
next approach is not to use blockpos, but something like BlockPos/2..3..4
in this case cache will be used more efficiently, as entity will be able to do small movements. good for mobs
The text was updated successfully, but these errors were encountered:
you only store world capability data, no data per chunk
WorldRadiation
sourceMap <long, SourceTable> - stores the data
long represents BlockPos, and SourceTable stores all sources for that pos
update() method iterates map and calls update for each RadSource
same time we need to keep updated map with calculated data for faster simulation of radiation at any coordinates, will use that to get exposure for livingentities
calculatedMap <long or BlockPos, int radiation>
SourceTable
map or list of RadSources
RadSource
sourceID - (int) will use it to fallback radiation source backend (object) from our registry
timestamp - (int) last updated time
lifetime - int how long this source exists
radiation - digital value of radiation
update() - updates radiation value by current timestamp
RadSourceBackend
int[] stages - contains vector values how source radiation changes during time
during update we split decay_time by amount of stages and apply stage value for radiation change
so for any source we can define any behavior
for example int[]{4, 2, 0, -1, -4}
means it will increase radiation faster at the beginning of decay_time, then it will slowdown and after that will decrease radiation
int initial_radioactivity
int decay_time
cache closest sources by entity pos. so if player stays in one place, algorithm won't have to iterate all know sources each time
and also we don't need to simulate that every tick, as we have timestamps we can simulate every second or whatever
next approach is not to use blockpos, but something like BlockPos/2..3..4
in this case cache will be used more efficiently, as entity will be able to do small movements. good for mobs
The text was updated successfully, but these errors were encountered: