diff --git a/lib/src/basic/types/area.dart b/lib/src/basic/types/area.dart index f5d3346..ca976a8 100644 --- a/lib/src/basic/types/area.dart +++ b/lib/src/basic/types/area.dart @@ -67,7 +67,7 @@ class Area { dz = (loc2.z - loc1.z).abs(); } - Map getRanges() { + Map getRanges() { var ret = {}; ret['x'] = loc1.x; ret['y'] = loc1.y; diff --git a/lib/src/basic/types/entity.dart b/lib/src/basic/types/entity.dart index 48c19c6..b04a544 100644 --- a/lib/src/basic/types/entity.dart +++ b/lib/src/basic/types/entity.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names import 'package:objd/core.dart'; +import 'package:deep_collection/deep_collection.dart'; export 'entities.dart'; abstract class EntityClass { @@ -287,7 +288,7 @@ class Entity extends GsonValue implements EntityClass { Entity.clone(Entity ent) : selector = ent.selector, playerName = ent.playerName, - arguments = Map.from(ent.arguments); + arguments = ent.arguments.deepCopy(); /// Entity is an util class to convert an argument list into the Minecraft Entity format(@p...) Entity({ diff --git a/pubspec.yaml b/pubspec.yaml index c46387b..202eb48 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,6 +11,7 @@ environment: dependencies: ansicolor: ^2.0.1 archive: ^3.3.7 + deep_collection: ^1.0.2 gson: ^0.1.6-dev dev_dependencies: lints: ^3.0.0 diff --git a/test/entity_clone_test.dart b/test/entity_clone_test.dart new file mode 100644 index 0000000..64cf2ae --- /dev/null +++ b/test/entity_clone_test.dart @@ -0,0 +1,22 @@ +import 'package:objd/core.dart'; +import 'package:test/test.dart'; + +import 'test_widget.dart'; + +void main() { + group('Entity Clone', () { + Entity newEntity = Entity(tags: ['test']); + Entity clonedEntity = newEntity.copyWith(tags: ['testCloned']); + + command( + 'Original Entity', + Execute.as(newEntity, children: [Say("hi")]), + 'execute as @e[tag=test] run say hi', + ); + command( + 'Cloned Entity', + Execute.as(clonedEntity, children: [Say("hi")]), + 'execute as @e[tag=test,tag=testCloned] run say hi', + ); + }); +}