From bc9f3e89e0b3ad8a1ef3033cce15904198e0a8d3 Mon Sep 17 00:00:00 2001 From: gnembon Date: Thu, 20 Aug 2020 23:24:16 -0300 Subject: [PATCH] added health and portal_cooldown --- .../mixins/ServerChunkManager_tickMixin.java | 5 +- .../assets/carpet/scripts/ai_tracker.sc | 51 ++++++++++++++++--- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/main/java/carpet/mixins/ServerChunkManager_tickMixin.java b/src/main/java/carpet/mixins/ServerChunkManager_tickMixin.java index 9e8cbf89..0dd3b461 100644 --- a/src/main/java/carpet/mixins/ServerChunkManager_tickMixin.java +++ b/src/main/java/carpet/mixins/ServerChunkManager_tickMixin.java @@ -60,7 +60,10 @@ public abstract class ServerChunkManager_tickMixin private boolean skipChunkTicking(ServerWorld serverWorld) { boolean debug = serverWorld.isDebugWorld(); - if (!TickSpeed.process_entities) { + if (!TickSpeed.process_entities) + { + // simplified chunk tick iteration assuming world is frozen otherwise as suggested by Hadron67 + // to be kept in sync with the original injection source if (!debug){ List holders = Lists.newArrayList(((ThreadedAnvilChunkStorageInterface)threadedAnvilChunkStorage).getChunks()); Collections.shuffle(holders); diff --git a/src/main/resources/assets/carpet/scripts/ai_tracker.sc b/src/main/resources/assets/carpet/scripts/ai_tracker.sc index 08be77a2..bcbc1b95 100644 --- a/src/main/resources/assets/carpet/scripts/ai_tracker.sc +++ b/src/main/resources/assets/carpet/scripts/ai_tracker.sc @@ -10,6 +10,8 @@ Current supported actions - current selected paths for all living entities - movement speeds per block and coordinate - item pickup range + - portal cooldown timers + - health - buddy villager detection for villagers - hostile detection for villagers - iron golem spawning for villagers @@ -45,6 +47,8 @@ velocity() -> __toggle('velocity', null); villager_breeding() -> __toggle('villager_breeding', null); villager_buddy_detection() -> __toggle('villager_buddy_detection', null); item_pickup() -> __toggle('item_pickup', null); +portal_cooldown() -> __toggle('portal_cooldown', null); +health() -> __toggle('health', null); toggle_boxes() -> @@ -272,9 +276,12 @@ global_functions = { ppos = global_entity_positions:id; dpos = ppos-cpos; dpos = dpos*20/global_interval; - labels += ['xvel', 'x speed:', str('%.3f',dpos:0)]; - labels += ['yvel', 'y speed:', str('%.3f',dpos:1)]; - labels += ['zvel', 'z speed:', str('%.3f',dpos:2)]; + if (dpos != [0, 0, 0], + labels += ['speed', 'speed: ', str('%.3f',sqrt(reduce(dpos, _a+_*_, 0)))]; + labels += ['xvel', 'x speed:', str('%.3f',dpos:0)]; + labels += ['yvel', 'y speed:', str('%.3f',dpos:1)]; + labels += ['zvel', 'z speed:', str('%.3f',dpos:2)]; + ) ); global_entity_positions:id = pos(e); path = e ~ 'path'; @@ -287,6 +294,31 @@ global_functions = { ] }, + 'portal_cooldown' -> { + '*' -> [ + _(arg) -> _(e) -> ( + portal_timer = e~'portal_timer'; + if (portal_timer, + [[], [], [['portal', 'portal cooldown:', portal_timer]]] + , + [[], [], []] + ) + ), + , + null + ] + }, + + 'health' -> { + '*' -> [ + _(arg) -> _(e) -> ( + [[], [], [['health', 'health:', e~'health']]] + ), + , + null + ] + }, + 'pathfinding' -> { '*' -> [ _(arg) -> _(e) -> ( @@ -464,14 +496,21 @@ __handle_entity(e) -> if (labels_to_add, base_pos = [0.5, e~'height'+0.4, 0.5]; base_height = 0; + snap = if(e~'type'=='player', 'xyz', 'dxydz'); for (labels_to_add, if (length(_) == 2, [label, text] = _; - shapes_to_display += ['label', global_duration, 'text', label, 'value', text, 'pos', base_pos, 'follow', e, 'height', base_height, 'snap', 'dxydz']; + shapes_to_display += [ + 'label', global_duration, 'text', label, 'value', text, + 'pos', base_pos, 'follow', e, 'height', base_height, 'snap', snap]; , [label, annot, value] = _; - shapes_to_display += ['label', global_duration, 'text', format('gi '+annot), 'pos', base_pos, 'follow', e, 'height', base_height, 'align', 'right', 'indent', -0.2, 'snap', 'dxydz']; - shapes_to_display += ['label', global_duration, 'text', label,'value', value, 'pos', base_pos, 'follow', e, 'height', base_height, 'align', 'left', 'snap', 'dxydz']; + shapes_to_display += [ + 'label', global_duration, 'text', format('gi '+annot), 'pos', base_pos, + 'follow', e, 'height', base_height, 'align', 'right', 'indent', -0.2, 'snap', snap]; + shapes_to_display += [ + 'label', global_duration, 'text', label,'value', value, + 'pos', base_pos, 'follow', e, 'height', base_height, 'align', 'left', 'snap', snap]; ); base_height += 1; );