Keep the block display a few ticks after placing the real block to avoid flickering
This commit is contained in:
1 parent
38bb9c6dc8
commit
a262010c82
1 file changed
+8
-6
@@ -18,6 +18,10 @@ public class BlockTransition {
|
||||
/** Zeit vom Start bis der echte Block steht (Spawn-Vorlauf + Animation + Puffer). */
|
||||
public static final int TOTAL_TICKS = DURATION_TICKS + 3;
|
||||
private static final double START_SCALE = 0.3;
|
||||
// minimal kleiner als der Block: sobald der echte Block steht, verdeckt er das Display ohne Z-Fighting
|
||||
private static final double END_SCALE = 0.998;
|
||||
// der Client braucht nach dem Setzen ein, zwei Frames bis der Block sichtbar ist: so lange bleibt das Display
|
||||
private static final int OVERLAP_TICKS = 4;
|
||||
|
||||
public static void animate(Instance world, Pos from, Pos to, Block block, int delayTicks, Runnable onArrival) {
|
||||
world.scheduler().buildTask(() -> spawn(world, from, to, block, onArrival))
|
||||
@@ -44,16 +48,14 @@ public class BlockTransition {
|
||||
display.scheduler().buildTask(() -> {
|
||||
display.editEntityMeta(BlockDisplayMeta.class, meta -> {
|
||||
meta.setTransformationInterpolationStartDelta(0);
|
||||
meta.setScale(Vec.ONE);
|
||||
meta.setTranslation(Vec.ZERO);
|
||||
meta.setScale(new Vec(END_SCALE));
|
||||
meta.setTranslation(new Vec((1 - END_SCALE) / 2));
|
||||
});
|
||||
display.teleport(to);
|
||||
}).delay(TaskSchedule.tick(2)).schedule();
|
||||
|
||||
display.scheduler().buildTask(() -> {
|
||||
onArrival.run();
|
||||
display.remove();
|
||||
}).delay(TaskSchedule.tick(TOTAL_TICKS)).schedule();
|
||||
display.scheduler().buildTask(onArrival).delay(TaskSchedule.tick(TOTAL_TICKS)).schedule();
|
||||
display.scheduler().buildTask(display::remove).delay(TaskSchedule.tick(TOTAL_TICKS + OVERLAP_TICKS)).schedule();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user