tweaked line particle display and chunk display app

This commit is contained in:
gnembon committed 2020-07-27 22:10:13 -03:00
1 parent 0e24940b78
commit 7a1e05cfa1
2 files changed
+32 -10

No files matched your search

@@ -546,14 +546,13 @@ public class ShapeDispatcher
super.init(options);
from = vecFromValue(options.get("from"));
to = vecFromValue(options.get("to"));
if (from.equals(to)) throw new InternalExpressionException("Box dimensions are invalid - cannot draw a zero-size boxes");
}
@Override
public Consumer<ServerPlayerEntity> alternative()
{
ParticleEffect particle = replacementParticle();
double density = Math.max(2.0, from.distanceTo(to) /50) / (a+0.1);
double density = Math.max(2.0, from.distanceTo(to) /50/ (a+0.1)) ;
return p ->
{
if (p.dimension == shapeDimension)
@@ -629,7 +628,6 @@ public class ShapeDispatcher
super.init(options);
from = vecFromValue(options.get("from"));
to = vecFromValue(options.get("to"));
if (from.equals(to)) throw new InternalExpressionException("Line dimensions are invalid - cannot draw a zero-length lines");
}
@Override
@@ -1276,13 +1274,33 @@ public class ShapeDispatcher
public static int drawParticleLine(List<ServerPlayerEntity> players, ParticleEffect particle, Vec3d from, Vec3d to, double density)
{
if (isStraight(from, to, density)) return drawOptimizedParticleLine(players, particle, from, to, density);
double lineLengthSq = from.squaredDistanceTo(to);
if (lineLengthSq == 0) return 0;
Vec3d incvec = to.subtract(from).multiply(2*density/MathHelper.sqrt(lineLengthSq));
double distance = from.squaredDistanceTo(to);
if (distance == 0) return 0;
int pcount = 0;
if (distance < 100)
{
Random rand = players.get(0).getServerWorld().random;
int particles = (int)(distance/density)+1;
Vec3d towards = to.subtract(from);
for (int i = 0; i < particles; i++)
{
Vec3d at = from.add(towards.multiply( rand.nextDouble()));
for (ServerPlayerEntity player : players)
{
player.getServerWorld().spawnParticles(player, particle, true,
at.x, at.y, at.z, 1,
0.0, 0.0, 0.0, 0.0);
pcount ++;
}
}
return pcount;
}
if (isStraight(from, to, density)) return drawOptimizedParticleLine(players, particle, from, to, density);
Vec3d incvec = to.subtract(from).multiply(2*density/MathHelper.sqrt(distance));
for (Vec3d delta = new Vec3d(0.0,0.0,0.0);
delta.lengthSquared()<lineLengthSq;
delta.lengthSquared()<distance;
delta = delta.add(incvec.multiply(Expression.randomizer.nextFloat())))
{
for (ServerPlayerEntity player : players)
@@ -1,3 +1,4 @@
global_update_interval = 100;
global_chunk_colors = m(
// loaded ticking
l(3, l(0xAAdd0000, 0x66990000)), // lime, green
@@ -126,6 +127,9 @@ __chunk_visualizer_tick(p) ->
if (!global_running, return());
show_activity = (p~'holds':0 == 'redstone_torch');
yval = setup:'plot_center':1+16;
base_update = global_update_interval;
random_component = ceil(0.4*base_update);
duration_max = ceil(1.5*base_update);
in_dimension( setup:'plot_dimension',
l(sx, sy, sz) = setup:'source_center';
l(px, py, pz) = setup:'plot_center';
@@ -160,10 +164,10 @@ __chunk_visualizer_tick(p) ->
l(cached_status, expiry) = global_status_cache:source_pos;
changed = (status != cached_status);
if ( changed || (expiry < now),
global_status_cache:source_pos = l(status, now+100+floor(rand(40)));
global_status_cache:source_pos = l(status, now+base_update+floor(rand(random_component)));
bpos = l(dx/2, yval, dz/2);
bcol = global_chunk_colors:status:((dx+dz)%2);
shapes += l('box', 150, 'from', bpos, 'to', bpos + l(0.5,0,0.5),
shapes += l('box', duration_max, 'from', bpos, 'to', bpos + l(0.5,0,0.5),
'color', 0xffffff00, 'fill', bcol+128, 'follow', p, 'snap', 'xz');
if (changed,
pbcol = global_chunk_colors:cached_status:((dx+dz)%2);