Merge branch 'master' into 1.16
# Conflicts: # src/main/java/carpet/script/CarpetExpression.java # src/main/java/carpet/script/utils/ShapeDispatcher.java # src/main/java/carpet/script/utils/ShapesRenderer.java
This commit is contained in:
commit
9aa580cfa5
19 files changed
+1042
-265
No files matched your search
@@ -49,6 +49,11 @@ __command() ->
|
||||
print(' "/camera show": Show current path particles');
|
||||
print(' color of particles used is different for different players');
|
||||
print(' "/camera hide": Hide path display');
|
||||
print(' "/camera prefer_smooth_play": ');
|
||||
print(' Eat CPU spikes and continue as usual');
|
||||
print(' "/camera prefer_synced_play": ');
|
||||
print(' After CPU spikes jump to where you should be');
|
||||
|
||||
print('');
|
||||
''
|
||||
);
|
||||
@@ -483,6 +488,11 @@ hide() ->
|
||||
);
|
||||
|
||||
// runs the player on the path
|
||||
global_prefer_sync = false;
|
||||
|
||||
prefer_smooth_play() -> (global_prefer_sync = false; 'Smooth path play');
|
||||
prefer_synced_play() -> (global_prefer_sync = true; 'Synchronized path play');
|
||||
|
||||
play() ->
|
||||
(
|
||||
if (err = __is_not_valid_for_motion(), exit(err));
|
||||
@@ -501,6 +511,7 @@ play() ->
|
||||
global_playing_path = true;
|
||||
mspt = 1000 / 60;
|
||||
start_time = time();
|
||||
very_start = start_time;
|
||||
point = 0;
|
||||
p = __get_player();
|
||||
try (
|
||||
@@ -514,9 +525,14 @@ play() ->
|
||||
modify(p, 'location', v);
|
||||
point += 1;
|
||||
end_time = time();
|
||||
took = end_time - start_time;
|
||||
if (took < mspt, sleep(mspt-took));
|
||||
start_time = time()
|
||||
if (global_prefer_sync,
|
||||
should_be = very_start + mspt*point;
|
||||
if (end_time < should_be, sleep(should_be-end_time) )
|
||||
,
|
||||
took = end_time - start_time;
|
||||
if (took < mspt, sleep(mspt-took));
|
||||
start_time = time()
|
||||
)
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
global_chunk_colors = m(
|
||||
// loaded ticking
|
||||
l(3, l(0xAAdd0000, 0x66990000)), // lime, green
|
||||
l(2, l(0xFF000000, 0x88000000)), // red
|
||||
l(1, l(0xFFcc0000, 0xbbaa0000)), // yellowish
|
||||
// 'unloaded' (in memory, so rather 'inaccessible')
|
||||
l(0, l(0xcccccc00, 0x11111100)), // gray / hi constast
|
||||
// stable full generation (for '0's, all 1,2,3 are always 'full')
|
||||
l('full', l(0xbbbbbb00, 0x88888800)), // gray
|
||||
// unstable final bits
|
||||
l('heightmaps', l(0x33333300, 0x22222200)), // checker
|
||||
l('spawn', l(0x00333300, 0x00222200)), // checker
|
||||
l('light_gen', l(0x55550000, 0x44440000)), // checker
|
||||
// stable features
|
||||
l('features', l(0x88bb2200, 0x66882200)), // green muddled
|
||||
//stable terrain
|
||||
l('liquid_carvers', l(0x65432100, 0x54321000)), // browns
|
||||
//unstable terrain - not generated yet
|
||||
l('carvers', l(0x33003300, 0x22002200)), // checker
|
||||
l('surface', l(0x33330000, 0x22220000)), // checker
|
||||
l('noise', l(0x33000000, 0x22000000)), // checker
|
||||
l('biomes', l(0x00330000, 0x00220000)), // checker
|
||||
l('structure_references', l(0x00003300, 0x00002200)), // checker
|
||||
// stable
|
||||
l('structure_starts', l(0x66666600, 0x22222200)), // darkgrey
|
||||
// not stated yet
|
||||
l('empty', l(0xFF888800, 0xDD444400)), // pink
|
||||
// proper not in memory
|
||||
l(null , l(0xFFFFFF00, 0xFFFFFF00)), // hwite
|
||||
|
||||
// ticket types
|
||||
l('player', l(0x0000DD00, 0x00008800)), // blue
|
||||
l('portal', l(0xAA00AA00, 0xAA00AA00)), // purple
|
||||
l('dragon', l(0xAA008800, 0xAA008800)), // purple
|
||||
l('forced', l(0xAABBFF00, 0x8899AA00)), // blue
|
||||
l('light', l(0xFFFF0000, 0xBBBB0000)), // yellow
|
||||
l('post_teleport', l(0xAA00AA00, 0xAA00AA00)), // purple
|
||||
l('start', l(0xDDFF0000, 0xDDFF0000)), // lime, green
|
||||
// recent chunk requests
|
||||
l('unknown', l(0xFF55FF00, 0xff99ff00)) // pink purple
|
||||
);
|
||||
|
||||
// map representing current displayed chunkloading setup
|
||||
global_current_setup = null;
|
||||
|
||||
// which blocks in the inventory represent which dimension
|
||||
global_block_markers = m(
|
||||
l('netherrack', 'the_nether'),
|
||||
l('grass_block', 'overworld'),
|
||||
l('end_stone', 'the_end')
|
||||
);
|
||||
|
||||
__on_player_uses_item(player, item_tuple, hand) ->
|
||||
(
|
||||
if (hand != 'mainhand', return());
|
||||
if (!has(global_block_markers, item_tuple:0), return());
|
||||
if (item_tuple:1%16 != 0, return());
|
||||
new_setup = true;
|
||||
if (global_current_setup,
|
||||
new_setup = __remove_previous_setup(player)
|
||||
);
|
||||
if (!new_setup, return());
|
||||
tag = nbt('{}');
|
||||
put(tag:'Enchantments','[]');
|
||||
put(tag:'Enchantments', '{lvl:1s,id:"minecraft:protection"}', 0);
|
||||
inventory_set(player, player~'selected_slot', item_tuple:1, item_tuple:0, tag);
|
||||
__setup_tracker(player, item_tuple);
|
||||
);
|
||||
|
||||
__remove_previous_setup(new_player) ->
|
||||
(
|
||||
if (!global_current_setup, return());
|
||||
global_running = false;
|
||||
p = player();
|
||||
if (p &&
|
||||
global_block_markers:((item = inventory_get(p, global_current_setup:'inventory_slot')):0)==global_current_setup:'source_dimension' &&
|
||||
item:1 == global_current_setup:'radius' &&
|
||||
item:2,
|
||||
inventory_set(p, global_current_setup:'inventory_slot', item:1, item:0, null); // disenchant
|
||||
if( new_player == p && new_player~'selected_slot' == global_current_setup:'inventory_slot',
|
||||
disabled = true
|
||||
);
|
||||
);
|
||||
global_current_setup = null;
|
||||
!disabled
|
||||
);
|
||||
|
||||
__setup_tracker(player, item) ->
|
||||
(
|
||||
setup = m();
|
||||
setup:'player_name' = str(player);
|
||||
setup:'inventory_slot' = player ~ 'selected_slot';
|
||||
setup:'plot_dimension' = player ~ 'dimension';
|
||||
setup:'plot_center' = map(pos(player), floor(_))-l(0,1,0);
|
||||
setup:'radius' = item:1;
|
||||
setup:'source_dimension' = global_block_markers:(item:0);
|
||||
multiplier = 1;
|
||||
if (setup:'source_dimension' != setup:'plot_dimension',
|
||||
multiplier = if (
|
||||
setup:'source_dimension' == 'the_nether', 1/8,
|
||||
setup:'source_dimension' == 'the_end', 0,
|
||||
8);
|
||||
);
|
||||
setup:'source_center' = setup:'plot_center' * multiplier;
|
||||
print(setup:'source_dimension'+' around '+setup:'source_center'+' with '+setup:'radius'+' radius ('+ (2*setup:'radius'+1)^2 +' chunks)');
|
||||
|
||||
l(sx, sy, sz) = setup:'source_center';
|
||||
global_status_cache = m();
|
||||
loop( 2*setup:'radius'+1, dx = _ - setup:'radius';
|
||||
loop( 2*setup:'radius'+1, dz = _ - setup:'radius';
|
||||
source_pos = l(sx+16*dx,sy,sz+16*dz);
|
||||
global_status_cache:source_pos = l(null, 0);
|
||||
)
|
||||
);
|
||||
global_current_setup = setup;
|
||||
global_running = true;
|
||||
schedule(0, '__chunk_visualizer_tick', player);
|
||||
);
|
||||
|
||||
global_status_cache = m();
|
||||
|
||||
__chunk_visualizer_tick(p) ->
|
||||
(
|
||||
setup = global_current_setup;
|
||||
if(!setup, return());
|
||||
if (!global_running, return());
|
||||
show_activity = (p~'holds':0 == 'redstone_torch');
|
||||
yval = setup:'plot_center':1+16;
|
||||
in_dimension( setup:'plot_dimension',
|
||||
l(sx, sy, sz) = setup:'source_center';
|
||||
l(px, py, pz) = setup:'plot_center';
|
||||
source_center = setup:'source_center';
|
||||
radius = setup:'radius';
|
||||
source_dimension = setup:'source_dimension';
|
||||
|
||||
shapes = l();
|
||||
now = tick_time();
|
||||
|
||||
loop( 2*radius+1, dx = _ - radius;
|
||||
loop( 2*radius+1, dz = _ - radius;
|
||||
changed = false;
|
||||
source_pos = l(sx+16*dx,sy,sz+16*dz);
|
||||
status = in_dimension( source_dimension,
|
||||
loaded_status = loaded_status(source_pos);
|
||||
if (loaded_status > 0, loaded_status, generation_status(source_pos))
|
||||
);
|
||||
// will mix with light ticket
|
||||
if (status=='light', status = 'light_gen');
|
||||
|
||||
|
||||
if (loaded_status > 0,
|
||||
tickets = in_dimension( source_dimension, chunk_tickets(source_pos));
|
||||
for(tickets,
|
||||
l(type, level) = _;
|
||||
if (show_activity || type != 'unknown',
|
||||
status = type;
|
||||
);
|
||||
);
|
||||
);
|
||||
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)));
|
||||
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),
|
||||
'color', 0xffffff00, 'fill', bcol+128, 'follow', p, 'snap', 'xz');
|
||||
if (changed,
|
||||
pbcol = global_chunk_colors:cached_status:((dx+dz)%2);
|
||||
shapes += l('box', 0, 'from', bpos, 'to', bpos + l(0.5,0,0.5),
|
||||
'color', 0xffffff00, 'fill', pbcol+128, 'follow', p, 'snap', 'xz');
|
||||
);
|
||||
);
|
||||
);
|
||||
);
|
||||
draw_shape(shapes);
|
||||
);
|
||||
schedule(1, '__chunk_visualizer_tick', p)
|
||||
)
|
||||
@@ -98,7 +98,7 @@ __structure_renderer(player_name) ->
|
||||
l(from, to) = structure_data;
|
||||
total_size = _euclidean(from, to);
|
||||
density = max(10, total_size/10);
|
||||
draw_shape('box', 15, 'from', from, 'to', to+1, 'color', 0x00FFFFFF, 'width', 3, 'fill', 0x00FFFF22);
|
||||
draw_shape('box', 15, 'from', from, 'to', to+1, 'color', 0x00FFFFFF, 'line', 3, 'fill', 0x00FFFF22);
|
||||
structure_pieces = slice(sort_key(structure_pieces, _euclidean_sq((_:2+_:3)/2,ppos)), 0, config:'max_pieces');
|
||||
for (structure_pieces, l(piece, direction, from, to) = _;
|
||||
r = 255 - floor(128 * _i/config:'max_pieces');
|
||||
@@ -137,12 +137,14 @@ __chunk_renderer(player_name) ->
|
||||
b = 30;
|
||||
a = max(0, 255-player_distance);
|
||||
color = a+256*(b+256*(g+256*r));
|
||||
draw_shape('line', 15, 'from', top_00, 'to', top_10, 'color', color, 'width', 3);
|
||||
draw_shape('line', 15, 'from', top_10, 'to', top_11, 'color', color, 'width', 3);
|
||||
draw_shape('line', 15, 'from', top_11, 'to', top_01, 'color', color, 'width', 3);
|
||||
draw_shape('line', 15, 'from', top_01, 'to', top_00, 'color', color, 'width', 3);
|
||||
draw_shape('line', 15, 'from', top_00, 'to', top_11, 'color', color, 'width', 3);
|
||||
draw_shape('line', 15, 'from', top_01, 'to', top_10, 'color', color, 'width', 3);
|
||||
draw_shape(l(
|
||||
l('line', 15, 'from', top_00, 'to', top_10, 'color', color, 'line', 3),
|
||||
l('line', 15, 'from', top_10, 'to', top_11, 'color', color, 'line', 3),
|
||||
l('line', 15, 'from', top_11, 'to', top_01, 'color', color, 'line', 3),
|
||||
l('line', 15, 'from', top_01, 'to', top_00, 'color', color, 'line', 3),
|
||||
l('line', 15, 'from', top_00, 'to', top_11, 'color', color, 'line', 3),
|
||||
l('line', 15, 'from', top_01, 'to', top_10, 'color', color, 'line', 3)
|
||||
));
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user