Skip to content

Commit

Permalink
1.20 features
Browse files Browse the repository at this point in the history
execute summon, over, on,
interaction + display entities
time fixes
return widget
tests
  • Loading branch information
Stevertus committed Jun 10, 2023
1 parent 06bc54d commit 463f15d
Show file tree
Hide file tree
Showing 26 changed files with 8,881 additions and 7,605 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@

- added Biome and corresponding Biomes list
- added FillBiome Widget
- added Damage Widget
- added Execute.on, Execute.summon and Heightmap
- added Damage Widget
- added Return Widget and Score.setToFunction tranfering the return value to a score
- added new Time object for dealing with ticks, seconds, days and infinite Duration
- added Display Widget for spawing display objects
- added time extensions to number allowing to write `10.seconds`, `2.ticks`, `2.4.minutes` etc. to generate time objects
- added Display Widget for spawing display objects and animate them
- added Interaction Widget for spawing interaction entities
- added preview images of all items and blocks in dartdoc
- added unit tests for checking critical widgets automatically
- added DataModify string operations
- added CommandBuilder widget providing a abstract api to build commands with optional and varying components (mainly used internally)
- added << Score operator as an additional "set to" operator(same as >>)
- updated blocks, items, particles and entities to include content from 1.19.4 and 23w12a
- updated dependencies
- changed Score >> operator to also accept Widgets and Files
- changed project version to also accept decimal numbers like 19.4 for `1.19.4` and react accordingly
- fixed #25 ScoreTimerModule returning incorrect command with negative value
- fixed Storage.getData not generating namespace properly
Expand Down
8 changes: 8 additions & 0 deletions lib/src/basic/command_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ class CommandBuilder extends Widget {
);
}

CommandBuilder number(
num? val, {
List<String>? also,
String? prefix,
String? suffix,
}) =>
string(val?.toString(), also: also, prefix: prefix, suffix: suffix);

CommandBuilder string(
String? str, {
List<String>? also,
Expand Down
8 changes: 6 additions & 2 deletions lib/src/basic/file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,12 @@ class File extends Widget {
header: header,
);

File run({bool create = false}) =>
File.execute(path, pack: pack, create: create);
File run({bool create = false}) => File.execute(
path,
pack: pack,
create: create,
child: child,
);

Path fullPath([Path? p]) => inheritFolder && p != null
? p.append(path, type: 'mcfunction')
Expand Down
11 changes: 10 additions & 1 deletion lib/src/basic/score.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:objd/src/basic/file.dart';
import 'package:objd/src/basic/group.dart';
import 'package:objd/src/basic/rest_action.dart';
import 'package:objd/src/basic/widget.dart';
Expand Down Expand Up @@ -226,15 +227,20 @@ class Score extends RestActionAble {
}

/// assign value(int, Score, Data or Condition)
Score operator >>(dynamic other) {
Widget setTo(dynamic other) {
if (other is int) return set(other);
if (other is Score) return setEqual(other);
if (other is Data) return setToData(other);
if (other is Condition) return setToCondition(other);
if (other is Command) return setToResult(other);
if (other is File) return setToFunction(other);
if (other is Widget) return setToWidget(other);
throw ('Please use either a Score, Data, Condition, Command or an Int in the operator >>');
}

Widget operator >>(dynamic other) => setTo(other);
Widget operator <<(dynamic other) => setTo(other);

/// sets the score to a given value of int
Score set(int val) {
return addCommandRet(
Expand Down Expand Up @@ -376,6 +382,9 @@ class Score extends RestActionAble {
);
}

/// set to functions return value(or number of commands)
Group setToFunction(File file) => setToWidget(file.run(create: true));

/// sets the score to the success of the given Command
Score setToResult(Command commmand, {bool useSuccess = false}) {
return addCommandRet(
Expand Down
8 changes: 6 additions & 2 deletions lib/src/basic/time.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ class Time {

@override
String toString() {
if (ticks % _TICKSINDAY == 0) return '${ticks / _TICKSINDAY}d';
if (ticks % _TICKSINSECOND == 0) return '${ticks / _TICKSINSECOND}d';
if (ticks % (_TICKSINDAY / 2) == 0) {
return '${ticks / _TICKSINDAY}d'.replaceFirst('.0d', 'd');
}
if (ticks % (_TICKSINSECOND / 4) == 0) {
return '${ticks / _TICKSINSECOND}s'.replaceFirst('.0s', 's');
}
return ticks.toString();
}

Expand Down
145 changes: 75 additions & 70 deletions lib/src/basic/types/biomes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Biomes {
import cog
import requests
version = '1.20/snapshots/23w12a'
version = '1.20/releases-candidate/1.20.1-rc1'
res = requests.get(f'https://raw.githubusercontent.com/PixiGeko/Minecraft-generated-data/master/{version}/custom-generated/lists/worldgen/biome.txt')
blocks = []
Expand Down Expand Up @@ -53,7 +53,8 @@ class Biomes {
static const Biome deep_frozen_ocean = Biome('minecraft:deep_frozen_ocean');

/// _minecraft:deep_lukewarm_ocean_
static const Biome deep_lukewarm_ocean = Biome('minecraft:deep_lukewarm_ocean');
static const Biome deep_lukewarm_ocean =
Biome('minecraft:deep_lukewarm_ocean');

/// _minecraft:deep_ocean_
static const Biome deep_ocean = Biome('minecraft:deep_ocean');
Expand Down Expand Up @@ -125,13 +126,16 @@ class Biomes {
static const Biome ocean = Biome('minecraft:ocean');

/// _minecraft:old_growth_birch_forest_
static const Biome old_growth_birch_forest = Biome('minecraft:old_growth_birch_forest');
static const Biome old_growth_birch_forest =
Biome('minecraft:old_growth_birch_forest');

/// _minecraft:old_growth_pine_taiga_
static const Biome old_growth_pine_taiga = Biome('minecraft:old_growth_pine_taiga');
static const Biome old_growth_pine_taiga =
Biome('minecraft:old_growth_pine_taiga');

/// _minecraft:old_growth_spruce_taiga_
static const Biome old_growth_spruce_taiga = Biome('minecraft:old_growth_spruce_taiga');
static const Biome old_growth_spruce_taiga =
Biome('minecraft:old_growth_spruce_taiga');

/// _minecraft:plains_
static const Biome plains = Biome('minecraft:plains');
Expand Down Expand Up @@ -197,7 +201,8 @@ class Biomes {
static const Biome windswept_forest = Biome('minecraft:windswept_forest');

/// _minecraft:windswept_gravelly_hills_
static const Biome windswept_gravelly_hills = Biome('minecraft:windswept_gravelly_hills');
static const Biome windswept_gravelly_hills =
Biome('minecraft:windswept_gravelly_hills');

/// _minecraft:windswept_hills_
static const Biome windswept_hills = Biome('minecraft:windswept_hills');
Expand All @@ -216,70 +221,70 @@ class Biomes {
for b in blocks:
cog.outl(f'{b},')
]]]*/
badlands,
bamboo_jungle,
basalt_deltas,
beach,
birch_forest,
cherry_grove,
cold_ocean,
crimson_forest,
dark_forest,
deep_cold_ocean,
deep_dark,
deep_frozen_ocean,
deep_lukewarm_ocean,
deep_ocean,
desert,
dripstone_caves,
end_barrens,
end_highlands,
end_midlands,
eroded_badlands,
flower_forest,
forest,
frozen_ocean,
frozen_peaks,
frozen_river,
grove,
ice_spikes,
jagged_peaks,
jungle,
lukewarm_ocean,
lush_caves,
mangrove_swamp,
meadow,
mushroom_fields,
nether_wastes,
ocean,
old_growth_birch_forest,
old_growth_pine_taiga,
old_growth_spruce_taiga,
plains,
river,
savanna,
savanna_plateau,
small_end_islands,
snowy_beach,
snowy_plains,
snowy_slopes,
snowy_taiga,
soul_sand_valley,
sparse_jungle,
stony_peaks,
stony_shore,
sunflower_plains,
swamp,
taiga,
the_end,
the_void,
warm_ocean,
warped_forest,
windswept_forest,
windswept_gravelly_hills,
windswept_hills,
windswept_savanna,
wooded_badlands,
badlands,
bamboo_jungle,
basalt_deltas,
beach,
birch_forest,
cherry_grove,
cold_ocean,
crimson_forest,
dark_forest,
deep_cold_ocean,
deep_dark,
deep_frozen_ocean,
deep_lukewarm_ocean,
deep_ocean,
desert,
dripstone_caves,
end_barrens,
end_highlands,
end_midlands,
eroded_badlands,
flower_forest,
forest,
frozen_ocean,
frozen_peaks,
frozen_river,
grove,
ice_spikes,
jagged_peaks,
jungle,
lukewarm_ocean,
lush_caves,
mangrove_swamp,
meadow,
mushroom_fields,
nether_wastes,
ocean,
old_growth_birch_forest,
old_growth_pine_taiga,
old_growth_spruce_taiga,
plains,
river,
savanna,
savanna_plateau,
small_end_islands,
snowy_beach,
snowy_plains,
snowy_slopes,
snowy_taiga,
soul_sand_valley,
sparse_jungle,
stony_peaks,
stony_shore,
sunflower_plains,
swamp,
taiga,
the_end,
the_void,
warm_ocean,
warped_forest,
windswept_forest,
windswept_gravelly_hills,
windswept_hills,
windswept_savanna,
wooded_badlands,
//[[[end]]]
];
}
Expand Down
5 changes: 5 additions & 0 deletions lib/src/basic/types/block.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class Block {
return id + strState + strnbt;
}

Map<String, dynamic> getBlockState() => {
"Name": id,
if (states != null) "properties": states,
};

/// **Usage:**
/// ```dart
/// Block([minecraft_block_id]) // as string or
Expand Down
Loading

0 comments on commit 463f15d

Please sign in to comment.