diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dc38a2..1ff8b50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## 0.4.2 +**BREAKING** + +- changed the default for If.assignTag to Entity.Self as this is more common than Entity.Player + +**Fixes** + - added new Marker Widget to easily create new Markers(you can use it where ever Summon can be used) - added `Entity.Marker` selector that selects all markers with an optional data field - added `breakItem` to CustomBlock to manually specify the item that should be killed if player breaks the block @@ -7,7 +13,6 @@ - updated ReplaceItem to reflect all the changes to the /item command - changed the list in For to be non nullable - changed CustomBlock break distance to 0.5(instead of 1) -- changed the default for If.assignTag to Entity.Self as this is more common than Entity.Player - changed behaviour of Condition.not when used with a tag, this will generate [tag=!name] now instead of unless - fixed `List` is not a subtype of type `Widget` diff --git a/README.md b/README.md index adeb533..e452c32 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Open the pubspec.yaml file and add ```yaml name: [unique_namespace] dependencies: - objd: ^0.4.1 + objd: ^0.4.2 ``` Also remember to replace the `[unique_namespace]` with your own project name. diff --git a/lib/src/basic/widget.dart b/lib/src/basic/widget.dart index 46f96fe..bbbebda 100644 --- a/lib/src/basic/widget.dart +++ b/lib/src/basic/widget.dart @@ -3,5 +3,5 @@ import 'package:objd/src/build/build.dart'; /// A widget is the base element for basically everything in objD. abstract class Widget { dynamic generate(Context context); - dynamic? toMap() => null; + dynamic toMap() => null; } diff --git a/lib/src/utils/marker.dart b/lib/src/utils/marker.dart index 9f343cd..9622142 100644 --- a/lib/src/utils/marker.dart +++ b/lib/src/utils/marker.dart @@ -1,6 +1,5 @@ import 'package:objd/src/basic/types/entity.dart'; import 'package:objd/src/basic/types/location.dart'; -import 'package:objd/src/basic/text_components.dart'; import 'package:objd/src/basic/widgets.dart'; import 'package:objd/src/wrappers/summon.dart'; diff --git a/lib/src/utils/storage.dart b/lib/src/utils/storage.dart index 4969159..8093e4a 100644 --- a/lib/src/utils/storage.dart +++ b/lib/src/utils/storage.dart @@ -34,7 +34,7 @@ class Storage extends Widget { this.autoNamespace = true, required String key, required dynamic value, - }) : nbt = {key: value}, + }) : nbt = {key: value}, key = key, _type = _StorageType.merge; @@ -43,7 +43,7 @@ class Storage extends Widget { this.name, { this.autoNamespace = true, required this.nbt, - }) : assert(nbt != null), + }) : assert(nbt != null), _type = _StorageType.merge; /// To get a value back, use Storage.get. @@ -52,7 +52,7 @@ class Storage extends Widget { this.autoNamespace = true, this.scale = 1, required this.key, - }) : assert(key != null), + }) : assert(key != null), _type = _StorageType.get; /// Removes certain Nbt Data. @@ -60,7 +60,7 @@ class Storage extends Widget { this.name, { this.autoNamespace = true, required this.key, - }) : assert(key != null), + }) : assert(key != null), _type = _StorageType.remove; /// Modifies Nbt Data(look at [Data Widget](/basics#data)). @@ -69,7 +69,7 @@ class Storage extends Widget { required String toPath, this.autoNamespace = true, required DataModify modify, - }) : _modify = modify, + }) : _modify = modify, key = toPath, _type = _StorageType.modify; @@ -79,7 +79,7 @@ class Storage extends Widget { this.autoNamespace = true, required this.key, required Data data, - }) : assert(key != null), + }) : assert(key != null), assert(data.subcommand == 'get', 'You have to insert a Data.get into copyData!'), data = data, @@ -93,7 +93,7 @@ class Storage extends Widget { this.datatype = 'byte', required this.key, required this.score, - }) : assert(score != null), + }) : assert(score != null), assert(key != null), _type = _StorageType.score; diff --git a/lib/src/utils/widgets.dart b/lib/src/utils/widgets.dart index 60e02e0..d64726a 100644 --- a/lib/src/utils/widgets.dart +++ b/lib/src/utils/widgets.dart @@ -16,3 +16,4 @@ export 'version_check.dart'; export 'pass_trait.dart'; export 'player_join.dart'; export 'recipe.dart'; +export 'marker.dart'; diff --git a/lib/src/wrappers/attribute.dart b/lib/src/wrappers/attribute.dart index 0f28693..e36f271 100644 --- a/lib/src/wrappers/attribute.dart +++ b/lib/src/wrappers/attribute.dart @@ -34,7 +34,7 @@ class Attribute extends RestActionAble { this.target, this.attribute, { required this.value, - }) : _type = _AttributeType.set, + }) : _type = _AttributeType.set, assert(value != null); /// removes a modifier with an uuid again @@ -42,7 +42,7 @@ class Attribute extends RestActionAble { this.target, this.attribute, { required this.uuid, - }) : _type = _AttributeType.remove, + }) : _type = _AttributeType.remove, assert(uuid != null); ///gets the calculated modifier(with base, armor and custom) diff --git a/lib/src/wrappers/execute.dart b/lib/src/wrappers/execute.dart index 5ed0765..c79853f 100644 --- a/lib/src/wrappers/execute.dart +++ b/lib/src/wrappers/execute.dart @@ -34,7 +34,7 @@ class Execute extends RestActionAble { this.children = const [], Entity? as, Entity? at, - dynamic? location, + dynamic location, String? align, this.targetFilePath = 'objd', this.targetFileName, @@ -68,7 +68,7 @@ class Execute extends RestActionAble { required Function(List) run, Entity? as, Entity? at, - dynamic? location, + dynamic location, String? align, String targetFilePath = 'objd', String? targetFileName, diff --git a/lib/src/wrappers/if.dart b/lib/src/wrappers/if.dart index e7886ac..7f0c0a1 100644 --- a/lib/src/wrappers/if.dart +++ b/lib/src/wrappers/if.dart @@ -134,9 +134,13 @@ class If extends RestActionAble { ), ); }); + final prefix = 'execute' + + (assignTag == null || assignTag!.selector == 's' + ? '' + : ' as $assignTag'); + children.add(Group( - prefix: - 'execute as ' + assignTag.toString() + ' if entity @s[tag=$tag] run', + prefix: '$prefix if entity @s[tag=$tag] run', path: targetFilePath, generateIDs: targetFileName == null, filename: targetFileName ?? 'if', @@ -145,9 +149,7 @@ class If extends RestActionAble { if (orElse != null) { children.add( Group( - prefix: 'execute as ' + - assignTag.toString() + - ' unless entity @s[tag=$tag] run', + prefix: '$prefix unless entity @s[tag=$tag] run', path: targetFilePath, filename: 'else', groupMin: encapsulate ? 3 : -1,