diff --git a/src/main/java/carpet/mixins/BiomeArray_cleanLogsMixin.java b/src/main/java/carpet/mixins/BiomeArray_cleanLogsMixin.java new file mode 100644 index 00000000..cf7fc1a0 --- /dev/null +++ b/src/main/java/carpet/mixins/BiomeArray_cleanLogsMixin.java @@ -0,0 +1,21 @@ +package carpet.mixins; + +import carpet.CarpetSettings; +import net.minecraft.world.biome.source.BiomeArray; +import org.apache.logging.log4j.Logger; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(BiomeArray.class) +public class BiomeArray_cleanLogsMixin +{ + @Redirect(method = "(Lnet/minecraft/util/collection/IndexedIterable;[I)V", at = @At( + value = "INVOKE", + target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;)V") + ) + private void skipLog(Logger logger, String message) + { + if (!CarpetSettings.cleanLogs) logger.warn(message); + } +} diff --git a/src/main/java/carpet/network/ClientNetworkHandler.java b/src/main/java/carpet/network/ClientNetworkHandler.java index cf5b6379..9a34ec2d 100644 --- a/src/main/java/carpet/network/ClientNetworkHandler.java +++ b/src/main/java/carpet/network/ClientNetworkHandler.java @@ -22,7 +22,7 @@ import java.util.function.BiConsumer; public class ClientNetworkHandler { - private static Map> dataHandlers = new HashMap>(); + private static final Map> dataHandlers = new HashMap>(); static { dataHandlers.put("Rules", (p, t) -> { @@ -61,7 +61,7 @@ public class ClientNetworkHandler if (rule != null) { String value = ruleNBT.getString("Value"); - rule.set(null, value); + try { rule.set(null, value); } catch (Exception ignored) { } } } }); @@ -133,8 +133,15 @@ public class ClientNetworkHandler if (compound == null) return; for (String key: compound.getKeys()) { - if (dataHandlers.containsKey(key)) - dataHandlers.get(key).accept(player, compound.get(key)); + if (dataHandlers.containsKey(key)) { + try { + dataHandlers.get(key).accept(player, compound.get(key)); + } + catch (Exception exc) + { + CarpetSettings.LOG.info("Corrupt carpet data for "+key); + } + } else CarpetSettings.LOG.error("Unknown carpet data: "+key); } diff --git a/src/main/java/carpet/script/utils/FixedCommandSource.java b/src/main/java/carpet/script/utils/FixedCommandSource.java index 939cb9d2..beb5e566 100644 --- a/src/main/java/carpet/script/utils/FixedCommandSource.java +++ b/src/main/java/carpet/script/utils/FixedCommandSource.java @@ -37,7 +37,7 @@ public class FixedCommandSource extends ServerCommandSource public FixedCommandSource(ServerCommandSource original, Vec3d pos, Value[] error, List chatOutput) { super(CommandOutput.DUMMY, pos, Vec2f.ZERO, original.getWorld(), CarpetSettings.runPermissionLevel, - original.getName(), original.getDisplayName(), original.getMinecraftServer(), original.getEntity(), true, + original.getName(), original.getDisplayName(), original.getMinecraftServer(), original.getEntity(), false, (ctx, succ, res) -> { }, EntityAnchorArgumentType.EntityAnchor.FEET); position = pos; world = original.getWorld(); @@ -80,11 +80,9 @@ public class FixedCommandSource extends ServerCommandSource return this; } - @Override - public ServerCommandSource withSilent() - { - return this; - } + //@Override // only used in fuctions and we really don't care to track these actually, besides the basic output + // also other overrides target ONLY execute command, which withSilent doesn't care bout. + //public ServerCommandSource withSilent() { return this; } @Override public ServerCommandSource withLevel(int level) diff --git a/src/main/resources/assets/carpet/scripts/ai_tracker.sc b/src/main/resources/assets/carpet/scripts/ai_tracker.sc index 058a2c34..365460ba 100644 --- a/src/main/resources/assets/carpet/scripts/ai_tracker.sc +++ b/src/main/resources/assets/carpet/scripts/ai_tracker.sc @@ -1,4 +1,4 @@ -__command() -> ' +_command() -> ' ai_tracker allows to display some extra information about various entities AI activity @@ -18,73 +18,13 @@ Current supported actions - breeding info for villagers Settings you may want to change - - toggle_boxes: hides/shows large boxes and spheres + - toggle boxes: hides/shows large boxes and spheres - update_frequency: changes update speed - clear: removes all options - transparency: default opacity of shapes, 8 for start '; -global_duration = 12; -global_interval = 10; - -global_opacity = 8; - -global_display_boxes = true; - - - -global_range = 48; - -// list of triples - [entity_type, feature, callback] -global_active_functions = []; -global_feature_switches = {}; -global_tracker_running = false; - -villager_iron_golem_spawning() -> __toggle('villager_iron_golem_spawning', null); -pathfinding() -> __toggle('pathfinding', null); -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); -xpstack() -> __toggle('xpstack', null); //1.17 feature - -toggle_boxes() -> -( - global_display_boxes = !global_display_boxes; - null; -); - -update_frequency(ticks) -> -( - if (type(ticks) != 'number' || ticks <=0 || ticks > 100, exit('Ticks needs to be a positive number from 1 to 100')); - global_interval = ticks; - global_duration = ticks + 2; - null; -); - -transparency(alpha) -> -( - if (type(alpha) != 'number' || alpha <=0 || alpha > 255, exit('Ticks needs to be a number from 0 to 255')); - global_opacity = floor(alpha); - null; -); - - - -villager_hostile_detection(hostile) -> -( - if (!has(global_hostile_to_villager:hostile), - print(player(), 'Unknown hostile that affects villagers, possible options are: '+keys(global_hostile_to_villager)); - exit(null); - ); - __toggle('villager_hostile_detection', hostile); -); - -global_entity_positions = {}; - global_functions = { 'villager_iron_golem_spawning' -> { 'villager' -> [ @@ -378,6 +318,57 @@ global_functions = { }, }; +global_hostile_to_villager = { + 'drowned' -> 8, + 'evoker'-> 12, + 'husk' -> 8, + 'illusioner' -> 12, + 'pillager' -> 15, + 'ravager' -> 12, + 'vex' -> 8, + 'vindicator' -> 10, + 'zoglin' -> 10, + 'zombie' -> 8, + 'zombie_villager' -> 8 +}; + + +__config() ->{ + 'commands'->{ + ''->'_command', + 'clear'->'clear', + 'toggle_boxes'->_()->global_display_boxes = !global_display_boxes, + ''->['__toggle',null], + 'villager '->_(d)->__toggle('villager_'+d,null), + 'villager hostile_detection '->_(h)->__toggle('villager_hostile_detection',h), + 'update_frequency '->_(ticks)->(global_interval = ticks;global_duration = ticks + 2), + 'transparency '->_(alpha)->global_opacity = alpha + }, + 'arguments'->{ + 'display'->{'type'->'term','options'->['item_pickup','velocity','portal_cooldown','health','pathfinding','xpstack']}, + 'aspect'->{'type'->'term','options'->['iron_golem_spawning','buddy_detection','hostile_detection','breeding']}, + 'ticks'->{'type'->'int','min'->0,'max'->100}, + 'alpha'->{'type'->'int','min'->0,'max'->255}, + 'hostile'->{'type'->'term','options'->keys(global_hostile_to_villager)} + } +}; + +global_duration = 12; +global_interval = 10; + +global_opacity = 8; + +global_display_boxes = true; + +global_range = 48; + +// list of triples - [entity_type, feature, callback] +global_active_functions = []; +global_feature_switches = {}; +global_tracker_running = false; + +global_entity_positions = {}; + global_villager_food = { 'bread' -> 4, 'potato' -> 1, @@ -426,29 +417,12 @@ __mark_path_element(path_element, visuals) -> ) ); -global_hostile_to_villager = { - 'drowned' -> 8, - 'evoker'-> 12, - 'husk' -> 8, - 'illusioner' -> 12, - 'pillager' -> 15, - 'ravager' -> 12, - 'vex' -> 8, - 'vindicator' -> 10, - 'zoglin' -> 10, - 'zombie' -> 8, - 'zombie_villager' -> 8 -}; - __is_hostile(v, m) -> ( mob = m~'type'; has(global_hostile_to_villager:mob) && (sqrt(reduce(pos(v)-pos(m), _a+_*_ , 0)) <= global_hostile_to_villager:mob) ); -__distance(v1, v2) -> sqrt(reduce(v1-v2,_a+_*_ ,0)); - - __toggle(feature, arg) -> ( @@ -576,5 +550,3 @@ __handle_entity(e) -> ); draw_shape(shapes_to_display); ); - - diff --git a/src/main/resources/assets/carpet/scripts/distance_beta.sc b/src/main/resources/assets/carpet/scripts/distance_beta.sc index 34acbd4f..c4ad94cf 100644 --- a/src/main/resources/assets/carpet/scripts/distance_beta.sc +++ b/src/main/resources/assets/carpet/scripts/distance_beta.sc @@ -60,13 +60,13 @@ global_generators = { _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], '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', 'right', 'indent', -1.5, 'text',format('rb Euclidean:')]; 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'); _); + map(shapes, put(_, 1, [40, 'player', player()], 'extend'); _); ); __mktp(pos) -> str('!/tp %.6f %.6f %.6f', pos); @@ -77,9 +77,8 @@ set_start(pos)->( ); set_mode(mode)->( - if (global_display_modes ~ mode, - global_current_mode = mode - ) + global_current_mode = mode; + print(player(),format('gi Set display mode to '+mode)) ); calculate(end)->( diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index d56769f7..026c8537 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -220,6 +220,7 @@ "DebugRenderer_scarpetRenderMixin", "WorldRenderer_scarpetRenderMixin", + "BiomeArray_cleanLogsMixin", "SoundEngineInt_cleanLogsMixin", "SoundSystem_cleanLogsMixin" ],