Merge branch 'master' into scoreboard-criterion-mod
This commit is contained in:
63 files changed
+2386
-797
No files matched your search
@@ -145,9 +145,8 @@ global_functions = {
|
||||
[10+half_width,10+height,10+half_width],
|
||||
0x65432100, 'buddy detection', false
|
||||
);
|
||||
[x,y,z] = pos(e);
|
||||
current_id = e~'id';
|
||||
buddies = entity_area('villager', x, y+height/2, z, 10+half_width, 10+height/2, 10+half_width);
|
||||
buddies = entity_area('villager', e, 10, 10, 10);
|
||||
nb = length(buddies);
|
||||
for (filter(buddies, _~'id' != current_id),
|
||||
visuals+=['line', global_duration, 'from', pos(e), 'to', pos(_), 'color', 0xffff00ff];
|
||||
@@ -518,9 +517,8 @@ __tick_tracker() ->
|
||||
return()
|
||||
);
|
||||
p = player();
|
||||
[px, py, pz] = pos(p);
|
||||
in_dimension(p,
|
||||
for (entity_area('valid', px, py, pz, global_range, global_range, global_range),
|
||||
for (entity_area('valid', p, global_range, global_range, global_range),
|
||||
__handle_entity(_)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1,91 +1,155 @@
|
||||
import('math','_euclidean','_manhattan','_round');
|
||||
|
||||
global_display_modes = ['chat', 'line', 'centered_sphere', 'box'];
|
||||
|
||||
__config()->{
|
||||
'commands'->{
|
||||
'from <start>'->'set_start',
|
||||
'from <start> to <end>'->'_calculate',
|
||||
'to <end>'->_(end_pos)->(_calculate(null,end_pos)),
|
||||
'toggle_line'->'_toggle_line'
|
||||
'from <start> to <end>'-> _(start, end) -> (global_current_start = start; calculate(end)),
|
||||
'to <end>'-> 'calculate',
|
||||
'clear' -> _() -> global_display_shapes = [],
|
||||
'clear last' -> _() -> if(global_display_shapes, delete(global_display_shapes, -1)),
|
||||
'display <mode>' -> 'set_mode',
|
||||
'assist <assist>' -> 'set_assist',
|
||||
'assist none' -> _() -> set_assist(null),
|
||||
},
|
||||
'arguments' -> {
|
||||
'start' -> {'type' -> 'location'},
|
||||
'end' -> {'type' -> 'location'}
|
||||
'end' -> {'type' -> 'location'},
|
||||
'mode' -> {'type' -> 'term', 'options' -> global_display_modes },
|
||||
'assist' -> {'type' -> 'block', 'suggest' -> ['brown_carpet']},
|
||||
}
|
||||
};
|
||||
|
||||
global_start=null;
|
||||
global_end=null;
|
||||
global_current_start = null;
|
||||
global_display_shapes = [];
|
||||
global_renderer_running = false;
|
||||
global_current_mode = 'chat';
|
||||
|
||||
global_show_line=false;
|
||||
global_assist_block = null;
|
||||
|
||||
set_assist(block) ->
|
||||
(
|
||||
|
||||
if (block == null,
|
||||
global_assist_block = null;
|
||||
handle_event('player_places_block', null);
|
||||
handle_event('player_uses_item', null);
|
||||
|
||||
,
|
||||
global_assist_block = str(block);
|
||||
handle_event('player_places_block', 'on_player_places_block');
|
||||
handle_event('player_uses_item', 'on_player_uses_item');
|
||||
)
|
||||
);
|
||||
|
||||
global_generators = {
|
||||
'line' -> _(from, to) -> [
|
||||
['line', 'from',from,'to',to]
|
||||
],
|
||||
'centered_sphere' -> _(from, to) -> [
|
||||
['line', 'from',from,'to',to, 'line', 5, 'color', 0x88888888],
|
||||
['sphere', 'center',from,'radius',_euclidean(from,to)]
|
||||
],
|
||||
'box' -> _(from, to) -> [
|
||||
['line', 'from',from,'to',to, 'line', 5, 'color', 0x88888888],
|
||||
['box', 'from',from,'to',to]
|
||||
],
|
||||
};
|
||||
|
||||
_create_shapes(mode, from, to) ->
|
||||
(
|
||||
shapes = call(global_generators:mode, from+[0, 0.07, 0], to+[0, 0.07, 0]);
|
||||
shapes += ['label', 'pos',to+[0,0.2,0], 'align', 'right', 'indent', -1.5, 'text',format('rb Cylindrical:')];
|
||||
shapes += ['label', 'pos',to+[0,0.2,0], 'align', 'left', 'text',_round(_euclidean(from, [to:0, from:1, to:2]), 0.001)];
|
||||
shapes += ['label', 'pos',to+[0,0.2,0], 'height', 1, 'align', 'right', 'indent', -1.5, 'text',format('rb Manhattan:')];
|
||||
shapes += ['label', 'pos',to+[0,0.2,0], 'height', 1, 'align', 'left', 'text',_round(_manhattan(from,to),0.001)];
|
||||
shapes += ['label', 'pos',to+[0,0.2,0], 'height', 2, 'align', 'right', 'indent', -1.5, 'text',format('rb Euclidian:')];
|
||||
shapes += ['label', 'pos',to+[0,0.2,0], 'height', 2, 'align', 'left', 'text',_round(_euclidean(from,to),0.001)];
|
||||
map(shapes, put(_, 1, [20, 'player', player()], 'extend'); _);
|
||||
);
|
||||
|
||||
__mktp(pos) -> str('!/tp %.6f %.6f %.6f', pos);
|
||||
|
||||
set_start(pos)->(
|
||||
global_start = pos;
|
||||
global_end = null;
|
||||
global_current_start = pos;
|
||||
print(player(),format('gi Initial point set to: ', 'g '+pos, __mktp(pos)))
|
||||
);
|
||||
|
||||
_toggle_line()->(
|
||||
global_show_line= !global_show_line;
|
||||
if(global_show_line,
|
||||
print('Toggled lines on');
|
||||
_draw_line()
|
||||
, // else
|
||||
print('Toggled lines off')
|
||||
);
|
||||
);
|
||||
|
||||
_calculate(start_pos, end_pos)->(
|
||||
if(start_pos!=null,
|
||||
set_start(start_pos);
|
||||
calculate(end_pos)
|
||||
, // else
|
||||
if(global_start,
|
||||
calculate(end_pos),
|
||||
print(player(),format('r There was no initial point for '+player()));
|
||||
set_start(end_pos)
|
||||
)
|
||||
set_mode(mode)->(
|
||||
if (global_display_modes ~ mode,
|
||||
global_current_mode = mode
|
||||
)
|
||||
);
|
||||
|
||||
__on_player_places_block(player, item_tuple, hand, block) ->(
|
||||
if(block=='brown_carpet' && system_info('world_carpet_rules'):'carpets'=='true',
|
||||
calculate(end)->(
|
||||
if(global_current_start != null,
|
||||
measure(end)
|
||||
, // else
|
||||
print(player(),format('r No initial point selected'));
|
||||
)
|
||||
);
|
||||
|
||||
on_player_places_block(player, item_tuple, hand, block) ->
|
||||
(
|
||||
if(block==global_assist_block,
|
||||
effective_pos = pos(block)+[0.5, 0, 0.5];
|
||||
if(global_start==null||player~'sneaking',//wont complain for first carpet
|
||||
set_start(effective_pos),
|
||||
_calculate(null, effective_pos)
|
||||
if(global_current_start==null||player~'sneaking',//wont complain for first carpet
|
||||
set_start(effective_pos)
|
||||
, // else
|
||||
calculate(effective_pos)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
calculate(end_pos)->(
|
||||
global_end = end_pos;
|
||||
manhattan = _round(_manhattan(global_start, global_end),0.001);//rounding to nearest 0.01 for precision, but not ridiculous decimal places
|
||||
spherical = _round(_euclidean(global_start, global_end), 0.001);
|
||||
//useful for chunk distances etc.
|
||||
cylindrical = _round(_euclidean(global_start, [global_end:0, global_start:1, global_end:2]), 0.001);
|
||||
|
||||
|
||||
print(player(),format(
|
||||
'w Distance between ',
|
||||
'c '+str('[%.1f, %.1f, %.1f]', global_start), __mktp(global_start),
|
||||
'w and ',
|
||||
'c '+str('[%.1f, %.1f, %.1f]', global_end), __mktp(global_end), 'w :\n',
|
||||
'w - Spherical: ', 'wb '+spherical+'\n',
|
||||
'w - Cylindrical: ', 'wb '+cylindrical+'\n',
|
||||
'w - Manhattan: ', 'wb '+manhattan
|
||||
));
|
||||
|
||||
schedule(0,'_draw_line');
|
||||
);
|
||||
|
||||
_draw_line()->(
|
||||
if(global_show_line,//It will always draw from the global positions, so it will turn on if there is a line
|
||||
if ( global_start && global_end,
|
||||
draw_shape('line',20,'from',global_start,'to',global_end, 'player',player());
|
||||
draw_shape('label',20,'pos',global_end,'text',_round(_euclidean(global_start,global_end),0.001));
|
||||
);
|
||||
schedule(20,'_draw_line')
|
||||
on_player_uses_item(player, item_tuple, hand) ->
|
||||
(
|
||||
if (item_tuple:0 == global_assist_block && hand == 'mainhand',
|
||||
if (player ~'sneaking',
|
||||
global_current_mode = global_display_modes:(global_display_modes ~ global_current_mode + 1);
|
||||
display_title(player, 'actionbar', format('w Distance mode: ','e '+global_current_mode));
|
||||
,
|
||||
if(global_display_shapes, delete(global_display_shapes, -1))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
measure(end)->
|
||||
(
|
||||
if (global_current_start == null, return());
|
||||
start = global_current_start;
|
||||
if (global_current_mode == 'chat',
|
||||
manhattan = _round(_manhattan(start, end),0.001);//rounding to nearest 0.01 for precision, but not ridiculous decimal places
|
||||
spherical = _round(_euclidean(start, end), 0.001);
|
||||
//useful for chunk distances etc.
|
||||
cylindrical = _round(_euclidean(start, [end:0, start:1, end:2]), 0.001);
|
||||
|
||||
print(player(),format(
|
||||
'w Distance between ',
|
||||
'c '+str('[%.1f, %.1f, %.1f]', start), __mktp(start),
|
||||
'w and ',
|
||||
'c '+str('[%.1f, %.1f, %.1f]', end), __mktp(end), 'w :\n',
|
||||
'w - Spherical: ', 'wb '+spherical+'\n',
|
||||
'w - Cylindrical: ', 'wb '+cylindrical+'\n',
|
||||
'w - Manhattan: ', 'wb '+manhattan
|
||||
));
|
||||
, // else
|
||||
global_display_shapes += _create_shapes(global_current_mode, start, end);
|
||||
for (global_display_shapes, draw_shape(_) );
|
||||
if (!global_renderer_running,
|
||||
global_renderer_running = true;
|
||||
render()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
render()->(
|
||||
if (!global_display_shapes,
|
||||
global_renderer_running = false;
|
||||
return();
|
||||
);
|
||||
for (global_display_shapes,
|
||||
draw_shape(_);
|
||||
);
|
||||
schedule(20,'render')
|
||||
);
|
||||
@@ -20,7 +20,7 @@ __config() -> {
|
||||
'arguments'->{
|
||||
'center'->{'type'->'pos', 'loaded'->'true'},
|
||||
'radius'->{'type'->'int', 'suggest'->[], 'min'->0},//to avoid default suggestions
|
||||
'replacement'->{'type'->'block'},
|
||||
'replacement'->{'type'->'blockpredicate'},
|
||||
'height'->{'type'->'int', 'suggest'->[],'min'->0},
|
||||
'orientation'->{'type'->'term', 'suggest'->['x','y','z']},
|
||||
'pointing'->{'type'->'term','suggest'->['up','down']},
|
||||
@@ -32,9 +32,20 @@ __config() -> {
|
||||
|
||||
//"Boilerplate" code
|
||||
|
||||
_block_matches(existing, block_predicate) ->
|
||||
(
|
||||
[name, block_tag, properties, nbt] = block_predicate;
|
||||
|
||||
(name == null || name == existing) &&
|
||||
(block_tag == null || block_tags(existing, block_tag)) &&
|
||||
all(properties, block_state(existing, _) == properties:_) &&
|
||||
(!tag || tag_matches(block_data(existing), tag))
|
||||
);
|
||||
|
||||
set_block(x, y, z, block, replacement)-> (
|
||||
if(block != block(x, y, z),
|
||||
without_updates( if (set([x, y, z],block),
|
||||
existing = block(x, y, z);
|
||||
if(block != existing && (replacement && _block_matches(existing, replacement) ),
|
||||
without_updates( if (set(existing,block),
|
||||
global_affected += [x, y, z];
|
||||
));
|
||||
);
|
||||
|
||||
@@ -292,3 +292,14 @@ __on_player_picks_up_item(player, item) ->
|
||||
print(' Player '+player+' injects '+item);
|
||||
);
|
||||
|
||||
__on_player_trades(player, entity, buy_left, buy_right, sell) ->
|
||||
(
|
||||
print('');
|
||||
print('__on_player_trades(player, item)');
|
||||
print('player trades:');
|
||||
print(' - player: '+player);
|
||||
print(' - entity: '+ entity);
|
||||
print(' - buy_left: '+ buy_left);
|
||||
print(' - buy_right: '+ buy_right);
|
||||
print(' - sell: '+ sell)
|
||||
);
|
||||
@@ -36,22 +36,15 @@ __config() ->
|
||||
'slime_chunks' -> ['__toggle', 'slime_chunks', 'chunks'],
|
||||
'portal coordinates' -> ['__toggle', 'coords', 'portals'],
|
||||
'portal links' -> ['__toggle', 'links', 'portals'],
|
||||
'<shape> <radius> following <player>' -> ['display_shape', [null,0xffffffff], true],
|
||||
'<shape> <radius> at <player>' -> ['display_shape', [null,0xffffffff], false],
|
||||
'<shape> <radius> following <player> <color>' -> ['display_shape', true],
|
||||
'<shape> <radius> at <player> <color>' -> ['display_shape', false],
|
||||
'<shape> <radius> following <entities>' -> ['display_shape', [null,0xffffffff], true],
|
||||
'<shape> <radius> at <entities>' -> ['display_shape', [null,0xffffffff], false],
|
||||
'<shape> <radius> following <entities> <color>' -> ['display_shape', true],
|
||||
'<shape> <radius> at <entities> <color>' -> ['display_shape', false],
|
||||
'<shape> clear' -> 'clear_shape',
|
||||
'clear' -> 'clear',
|
||||
},
|
||||
'arguments' -> {
|
||||
'structure' -> {'type' -> 'term', 'suggest' -> [
|
||||
'monument', 'fortress', 'mansion', 'jungle_pyramid',
|
||||
'desert_pyramid', 'endcity', 'igloo', 'shipwreck',
|
||||
'swamp_hut', 'stronghold', 'ocean_ruin', 'buried_treasure',
|
||||
'pillager_outpost', 'mineshaft', 'village', 'nether_fossil',
|
||||
'bastion_remnant', 'ruined_portal'
|
||||
]},
|
||||
'player' -> {'type' -> 'players', 'single' -> true},
|
||||
'structure' -> {'type' -> 'term', 'suggest' -> plop():'structures' },
|
||||
'radius' -> {'type' -> 'int', 'min' -> 0, 'max' -> 1024, 'suggest' -> [128, 24, 32]},
|
||||
'shape' -> {'type' -> 'term', 'options' -> keys(global_shapes) },
|
||||
'color' -> {'type' -> 'teamcolor'}
|
||||
@@ -59,29 +52,30 @@ __config() ->
|
||||
};
|
||||
|
||||
|
||||
display_shape(shape, r, player, color, following) ->
|
||||
display_shape(shape, r, entities, color, following) ->
|
||||
(
|
||||
|
||||
player = player(player);
|
||||
if (!player, return());
|
||||
if (shape == 'sphere',
|
||||
shape_config = {
|
||||
'center' -> if(following, [0,0,0], pos(player)),
|
||||
'radius' -> r
|
||||
}
|
||||
, shape == 'box',
|
||||
shape_config = {
|
||||
'from' -> if(following, [-r,-r,-r], pos(player)-r),
|
||||
'to' -> if(following, [r,r,r], pos(player)+r)
|
||||
}
|
||||
);
|
||||
if (shape_config,
|
||||
if (following, shape_config:'follow' = player);
|
||||
shape_config:'fill' = color:1 - 200;
|
||||
shape_config:'color' = color:1;
|
||||
shape_config:'line' = 5;
|
||||
draw_shape(shape, 72000, shape_config);
|
||||
global_shapes:shape += shape_config;
|
||||
thicc = max(1, floor(6-length(entities)/2));
|
||||
fillc = 250 - 100/(length(entities)+1);
|
||||
for (entities,
|
||||
if (shape == 'sphere',
|
||||
shape_config = {
|
||||
'center' -> if(following, [0,0,0], pos(_)),
|
||||
'radius' -> r
|
||||
}
|
||||
, shape == 'box',
|
||||
shape_config = {
|
||||
'from' -> if(following, [-r,-r,-r], pos(_)-r),
|
||||
'to' -> if(following, [r,r,r], pos(_)+r)
|
||||
}
|
||||
);
|
||||
if (shape_config,
|
||||
if (following, shape_config:'follow' = _);
|
||||
shape_config:'fill' = color:1 - fillc;
|
||||
shape_config:'color' = color:1;
|
||||
shape_config:'line' = thicc;
|
||||
draw_shape(shape, 72000, shape_config);
|
||||
global_shapes:shape += shape_config;
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -166,11 +166,12 @@
|
||||
"PlayerInventory_scarpetEventMixin",
|
||||
"ScoreboardObjective_scarpetMixin",
|
||||
"Scoreboard_scarpetMixin",
|
||||
"TradeOutputSlot_scarpetEventMixin",
|
||||
|
||||
"ChunkTicketManager_scarpetMixin",
|
||||
"StatType_scarpetMixin",
|
||||
"PointOfInterest_scarpetMixin",
|
||||
"ServerWorld_scarpetEventMixin",
|
||||
"ServerWorld_scarpetMixin",
|
||||
"HungerManagerMixin_scarpetEventsMixin",
|
||||
|
||||
"RecipeManager_scarpetMixin",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "carpet",
|
||||
"version": "1.4.19",
|
||||
"version": "1.4.21",
|
||||
|
||||
"name": "Carpet Mod in Fabric",
|
||||
"description": "Carpet made out of fabric",
|
||||
|
||||
Reference in new issue
Block a user