objd 0.2.4

objD #

Objective Builder Just for Datapacks

objD is a framework for developing Datapacks for Minecraft. It uses the Dart programming language.

Why a framework? #

A framework is a set of utilities to reduce the amount of repetitive work. I've tried many ways in the past to achieve a quick and easy way to generate Datapacks for Minecraft: A own programming language mcscript, several graphical online generators at stevertus.com or premade utilities.

Instead of developing a language, why not using the tools and parser an other language gives you? By building a custom frame around it you get the reliability and the extensive debugging tools in Editors.

The generation of Datapacks is easy,fast and aims to be less repetitive and modular by utilizing the concept of Widgets as one of the main features.

Installation #

[Temporary]

You need the Dart SDK for this framework. Download and install it from https://www.dartlang.org/tools/sdk

I would also recommend Visual Studio Code along with the dart plugin to edit dart files very conveniently.

Make a new folder that will house your project wherever you want(I would recommend datapacks folder).

And inside of that create a file named pubspec.yaml and another folder called lib.

Open the pubspec.yaml file and add

name: [unique_namespace]
dependencies:  
   objd: ^0.2.4

Also remember to replace the [unique_namespace] with your own project name. And run

$  pub get

with the console in the new folder(VS code does this automatically)

Tip: You can also generate a full project with a console command. read more

Getting started #

Let's get started and create our first dart file with lib/main.dart file.

Then we import the framework with:

import 'package:objd/core.dart';

Then we need to create a new datapack project:

void main(List<String> args){
	createProject(
		Project(
			name:"This is going to be the generated folder name",
			target:"./", // path for where to generate the project
			generate: CustomWidget() // The starting point of generation
		),
		args
	);
}

Next of we need to build this custom Widget:

class CustomWidget extends Widget {
	@override
	Widget generate(Context context){
		
	}
}

To get more details on why we build it like that, check out the Widget documentation.

Like we can see the generate method, which is called on build, has to return another Widget, in our case an instance of the Pack class.

Widget generate(Context context){
	return Pack(
		name:"mypack",
		main: File( // optional
			'main'
		)
	)
}

What we are doing right now is to generate a new subpack with a name(This will be the namespace of your functions later) and a main file(runs every tick) with the name "main.mcfunction".

You can run the project already and the result should be a pack with an empty main.mcfunction file.

So lets add some functionality to our project in our main file. We can use the Log Widget to display a message to the player.

main: File(
	'main',
	child: Log('Hello World')
)

But how to add a list of Actions then? Well there's also an Widget for that: For.of

child: For.of([
	Log('Hello World'),
	Command('setblock 0 0 0 air')
])

So now we have a List of Widget, so we can use as many as we want

Whole code:

import 'package:objd/core.dart';

void main(List<String> args){
    createProject(
        Project(
            name:"This is going to be the generated folder name",
            target:"./",
            generate: CustomWidget() 
        ),
        args
    );
}

class CustomWidget extends Widget {
    @override
    Widget generate(Context context){
        return Pack(
            name:"mypack",
            main: File( // optional
                'main',
                child: For.of([
			Log('Hello World'),
			Command('setblock 0 0 0 air')
		])
            )
        );
    }
}

Documentation and Examples #

The example folder contains a boilerplate to start off.

There are many more widgets for objD including basic Widgeds, Command Wrappers, Text and Util Widgets. So check out the documentation at https://stevertus.com/objD/documentation or my youtube channel https://www.youtube.com/stevertus. In this video playlist are all objD related videos: https://www.youtube.com/playlist?list=PL5AxRIlgrL5GnKz69w4AUyqpZC35BlxdD

0.2.4 #

  • added ClickEvent Module
  • added copyWith on Entities
  • added setValues on Entity to change selections afterwards
  • added Location.clone
  • added desc to Log
  • changed Color to const to allow defaults
  • changed Particle to use a double type for speed and no requirement for a location
  • fixed Particle.item to use ItemType instead of Item
  • fixed CommandList Type Error
  • fixed Raycast Error when not using stop in the ray property
  • fixed missing Invisible Nbt on ArmorStand

0.2.3 #

  • added new Module type to allow registering tick functions and files with a convenient api
  • added modules property to Pack to inject new modules
  • added ScoreTimerModule that implements a Timer using Scoreboards
  • changed Widget class to be abstract
  • tweaked Raycast to work properly
  • improved Entity.not
  • fixed TextComponent.space with negative numbers

0.2.2 #

  • added Item.clone, Entity.clone and similar Methods with ItemType and Slot to enrich changeable inputs
  • added Entity.not to negate arguments
  • added Slot.craft
  • added Clear Wrapper
  • added Condition.Data
  • added Block.nbt to include Nbt-data and Blockstates
  • added Score.findSmallest and Score.findBiggest
  • updated Item.getGiveNotation to include Damage
  • changed Slot utilities to use seperate row and column arguments
  • fixed missing minecraft: on Item nbt
  • fixed wrong order of scale and datatype for Data.fromScore

0.2.1 #

  • added experimental hotreload to boost performance
  • added new -hotreload and -full build arguments
  • added new Slot class with helper functions
  • added Advancement Widget
  • added Data.fromScore
  • added Rotation utilities like Rotation.n and Rotation.north
  • added Rotation.getDirection
  • added isRotated value on entities to test for a Rotation object
  • reworked ReplaceItem for Blocks and using the new Slot
  • updated Item Slot requirements to match the Slot datatype
  • updated project generator without File path
  • updated Getting Started to fit new requirements and systems
  • fixed Location.storeResult

0.2.0 #

  • Completly reworked build algorithms that run the generate method just once.
  • improved performace
  • added new build arguments in createProject
  • new build arguments -min -prod and -debug
  • access to the prod property on context to change widget behaviour in productive build
  • comments and line breaks get automatically removed in productive build
  • added Raycast Widgets with many options to choose from
  • added ForEach Loop that iterates through each score
  • added Do.Until and Do.While Loops
  • added a Book Generator with Item.Book that allows to use BookPages and TextComponents to fill a book
  • added a TextComponent for the negative Spaces Font by AmberW. This automatically calculates the customs chars for a specified pixel value.
  • added a TextComponent for Custom Fonts
  • added a TextComponent for Linebreaks
  • added number and boolean arguments for Log
  • added new Block Condition which tests the current Position after the block
  • updated Say Wrapper to either use a String or Entity in one argument
  • fixed missing encapsulate property on If.not
  • fixed double and unmatching group ids with multiple packs and widgets
  • fixed multiple scoreboard related bugs. All declared Scoreboards from all packs should generate in the load functions now
  • fixed TextClickEvent.runCommand to include a slash (Thanks Dommi)
  • fixed data modify command generator (Thanks Vinicius Rangel for pull)

0.1.3 #

  • added Bossbar
  • added nbt TextComponents
  • added encapsulate to If
  • added strNbt to Data and Entity to support unvalid json chars
  • reworked the global console commands and binaries
  • fixed data modify
  • fixed missing datatype and scale with entity.storeResult

0.1.2 #

  • added RandomScore
  • added a Team wrapper
  • added a team option for entities as well as joinTeam and leaveTeam methods
  • added Repeat to repeat code with delay
  • added Log Widget to quickly print Messages, Scores or Entities in the chat
  • added ArmorStand Widget to create an armorstand
  • added Hologram to display text
  • added AreaEffectCloud
  • added Tag.toggle
  • added a create option to File
  • added a nbt option for Setblock
  • added Score.fromSelected to avoid annoying Entity.Selected
  • changed summon arguments
  • changed effect to also support nbt effects
  • changed Location to optional arguments
  • fixed when there are two identical files that they would extend

0.1.1 #

  • added AroundLocation widget
  • added Trigger wrapper
  • added Effect wrapper
  • added Particle wrapper
  • added clone wrapper
  • added nbt option for entities
  • added score.con for constants
  • added display name and lore for items
  • changed global commands and boilerplate project
  • fixed execute align
  • fixed execute bug if targetPath was null
  • fixed timer not generating schedule

0.1 #

with the first proper release there are the first util classes:

  • added Timeout and Timer widgets for delays and clocks
  • added Tag widget
  • added Schedule widget
  • added scores and tags parameters in any entity constructor
  • added addTag, addTags and removeTag Methods on entity
  • added targetFilePath and targetFileName parameters for the execute and if constructors to force a folder or filename
  • added suffix option for groups
  • added tag condition
  • added compile time
  • added experimental global commands
  • changed if behaviour to use a Tag instead with or conditions, else statement or multiple then children
  • fixed: nested groups generated in the wrong order
  • fixed entity Range generating unvalid results for -10..0
  • fixed groups that generated a different file than execution name(still some issues)

0.0.10 #

  • added experimental if else statements(may be changed later on)
  • added an if option for execute as well
  • added the area class
  • fixed group
  • fixed requirement for slot and count for items
  • changed entity static functions to named constructors(for Entity.Selected...)
  • updated fill to use area instead
  • updated teleport to use rotation
  • updated to dart 2.1.1
  • added inline documentation for many widgets
  • split the build process into multiple files

0.0.9 #

  • added subcommands for execute
  • added methods for execute
  • added storeResult to Location and Entity
  • added Rotation
  • fixed reference issue for groups(they prefixed everything :o)

0.0.8 #

  • added Entity.PlayerName()
  • fixed readme
  • modified score.setToResult
  • made Block, EntityType and ItemType constants to use them in defaults

0.0.7 #

  • added score generation
  • added Scoreboard
  • added Score with calculation and condition methods
  • fixed that main and load functions were not executed

0.0.6 #

  • added teleport
  • added fill
  • added data widget and DataModify to edit nbt data
  • updated entity with area parameter

0.0.5 #

0.0.4 #

  • added Summon command wrapper
  • added TextComponents
  • added Title and Tellraw
  • added Color class
  • added TextClickEvent class
  • added TextHoverEvent class

0.0.3 #

  • added Block
  • added Location
  • added Setblock
  • added Say

0.0.2 #

  • Fixed ReadMe

0.0.1 #

  • Initial Project with Basics and Builder

example/example.dart

// import the core of the framework:
import 'package:objd/core.dart';
// import the custom pack:
import './packs/examplePack.dart';

void main(List<String> args) {
  createProject(
    Project(
      name: "folder name",
      target: "./",             // path for where to generate the project
      generate: ExamplePack(),  // The starting point of generation
    ),
    args
  );
}

Use this package as an executable

1. Install it

You can install the package from the command line:


$ pub global activate objd

2. Use it

The package has the following executables:


$ objd

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  objd: ^0.2.4

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:objd/basic/area.dart';
import 'package:objd/basic/block.dart';
import 'package:objd/basic/command.dart';
import 'package:objd/basic/condition.dart';
import 'package:objd/basic/entity.dart';
import 'package:objd/basic/extend.dart';
import 'package:objd/basic/file.dart';
import 'package:objd/basic/for_list.dart';
import 'package:objd/basic/group.dart';
import 'package:objd/basic/item.dart';
import 'package:objd/basic/location.dart';
import 'package:objd/basic/module.dart';
import 'package:objd/basic/pack.dart';
import 'package:objd/basic/rotation.dart';
import 'package:objd/basic/score.dart';
import 'package:objd/basic/scoreboard.dart';
import 'package:objd/basic/slot.dart';
import 'package:objd/basic/tag.dart';
import 'package:objd/basic/text.dart';
import 'package:objd/basic/text_components.dart';
import 'package:objd/basic/widget.dart';
import 'package:objd/basic/widgets.dart';
import 'package:objd/build/build.dart';
import 'package:objd/build/buildFile.dart';
import 'package:objd/build/buildPack.dart';
import 'package:objd/build/buildProject.dart';
import 'package:objd/build/context.dart';
import 'package:objd/build/findPack.dart';
import 'package:objd/build/io.dart';
import 'package:objd/build/project.dart';
import 'package:objd/build/reloader.dart';
import 'package:objd/build/scan.dart';
import 'package:objd/core.dart';
import 'package:objd/modules/click_event.dart';
import 'package:objd/modules/modules.dart';
import 'package:objd/modules/score_timer.dart';
import 'package:objd/utils/areaeffectcloud.dart';
import 'package:objd/utils/armorstand.dart';
import 'package:objd/utils/aroundlocation.dart';
import 'package:objd/utils/do_loop.dart';
import 'package:objd/utils/foreach.dart';
import 'package:objd/utils/hologram.dart';
import 'package:objd/utils/log.dart';
import 'package:objd/utils/randomScore.dart';
import 'package:objd/utils/raycast.dart';
import 'package:objd/utils/repeat.dart';
import 'package:objd/utils/timer.dart';
import 'package:objd/utils/widgets.dart';
import 'package:objd/wrappers/advancement.dart';
import 'package:objd/wrappers/bossbar.dart';
import 'package:objd/wrappers/clear.dart';
import 'package:objd/wrappers/clone.dart';
import 'package:objd/wrappers/comment.dart';
import 'package:objd/wrappers/data.dart';
import 'package:objd/wrappers/effect.dart';
import 'package:objd/wrappers/execute.dart';
import 'package:objd/wrappers/fill.dart';
import 'package:objd/wrappers/give.dart';
import 'package:objd/wrappers/if.dart';
import 'package:objd/wrappers/kill.dart';
import 'package:objd/wrappers/particle.dart';
import 'package:objd/wrappers/replaceitem.dart';
import 'package:objd/wrappers/say.dart';
import 'package:objd/wrappers/schedule.dart';
import 'package:objd/wrappers/setblock.dart';
import 'package:objd/wrappers/summon.dart';
import 'package:objd/wrappers/team.dart';
import 'package:objd/wrappers/teleport.dart';
import 'package:objd/wrappers/tellraw.dart';
import 'package:objd/wrappers/title.dart';
import 'package:objd/wrappers/trigger.dart';
import 'package:objd/wrappers/widgets.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
69
Health:
Code health derived from static analysis. [more]
64
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
68
Learn more about scoring.

We analyzed this package on Jul 19, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, other

Platform components identified in package: io.

Health suggestions

Fix lib/basic/condition.dart. (-4.41 points)

Analysis of lib/basic/condition.dart reported 9 hints, including:

line 65 col 29: DO use curly braces for all flow control structures.

line 66 col 12: DO use curly braces for all flow control structures.

line 73 col 29: DO use curly braces for all flow control structures.

line 74 col 12: DO use curly braces for all flow control structures.

line 103 col 27: DO use curly braces for all flow control structures.

Fix lib/basic/item.dart. (-2.96 points)

Analysis of lib/basic/item.dart reported 6 hints, including:

line 15 col 27: DO use curly braces for all flow control structures.

line 16 col 29: DO use curly braces for all flow control structures.

line 17 col 30: DO use curly braces for all flow control structures.

line 18 col 10: DO use curly braces for all flow control structures.

line 60 col 23: Use isNotEmpty instead of length

Fix lib/build/io.dart. (-2.96 points)

Analysis of lib/build/io.dart reported 6 hints, including:

line 28 col 27: Use isNotEmpty instead of length

line 33 col 35: Always true because length is always greater or equal 0.

line 34 col 13: DO use curly braces for all flow control structures.

line 35 col 35: Always true because length is always greater or equal 0.

line 36 col 13: DO use curly braces for all flow control structures.

Fix additional 71 files with analysis or formatting issues. (-33.32 points)

Additional issues in the following files:

  • lib/wrappers/if.dart (6 hints)
  • lib/basic/command.dart (5 hints)
  • lib/build/scan.dart (5 hints)
  • bin/objd.dart (4 hints)
  • lib/basic/entity.dart (4 hints)
  • lib/basic/slot.dart (4 hints)
  • lib/build/buildFile.dart (4 hints)
  • lib/utils/hologram.dart (4 hints)
  • lib/basic/block.dart (3 hints)
  • lib/basic/extend.dart (3 hints)
  • lib/basic/pack.dart (3 hints)
  • lib/wrappers/say.dart (3 hints)
  • lib/wrappers/teleport.dart (3 hints)
  • lib/utils/do_loop.dart (2 hints)
  • lib/utils/timer.dart (2 hints)
  • lib/basic/file.dart (1 hint)
  • lib/basic/group.dart (1 hint)
  • lib/basic/text_components.dart (1 hint)
  • lib/build/build.dart (1 hint)
  • lib/build/reloader.dart (1 hint)
  • lib/wrappers/clone.dart (1 hint)
  • lib/wrappers/data.dart (1 hint)
  • lib/wrappers/execute.dart (1 hint)
  • lib/wrappers/fill.dart (1 hint)
  • lib/wrappers/replaceitem.dart (1 hint)
  • lib/wrappers/team.dart (1 hint)
  • lib/wrappers/trigger.dart (1 hint)
  • bin/new.dart (Run dartfmt to format bin/new.dart.)
  • bin/run.dart (Run dartfmt to format bin/run.dart.)
  • bin/serve.dart (Run dartfmt to format bin/serve.dart.)
  • lib/basic/area.dart (Run dartfmt to format lib/basic/area.dart.)
  • lib/basic/for_list.dart (Run dartfmt to format lib/basic/for_list.dart.)
  • lib/basic/location.dart (Run dartfmt to format lib/basic/location.dart.)
  • lib/basic/module.dart (Run dartfmt to format lib/basic/module.dart.)
  • lib/basic/rotation.dart (Run dartfmt to format lib/basic/rotation.dart.)
  • lib/basic/score.dart (Run dartfmt to format lib/basic/score.dart.)
  • lib/basic/scoreboard.dart (Run dartfmt to format lib/basic/scoreboard.dart.)
  • lib/basic/tag.dart (Run dartfmt to format lib/basic/tag.dart.)
  • lib/basic/text.dart (Run dartfmt to format lib/basic/text.dart.)
  • lib/basic/widget.dart (Run dartfmt to format lib/basic/widget.dart.)
  • lib/basic/widgets.dart (Run dartfmt to format lib/basic/widgets.dart.)
  • lib/build/buildPack.dart (Run dartfmt to format lib/build/buildPack.dart.)
  • lib/build/buildProject.dart (Run dartfmt to format lib/build/buildProject.dart.)
  • lib/build/context.dart (Run dartfmt to format lib/build/context.dart.)
  • lib/build/findPack.dart (Run dartfmt to format lib/build/findPack.dart.)
  • lib/build/project.dart (Run dartfmt to format lib/build/project.dart.)
  • lib/core.dart (Run dartfmt to format lib/core.dart.)
  • lib/modules/click_event.dart (Run dartfmt to format lib/modules/click_event.dart.)
  • lib/modules/score_timer.dart (Run dartfmt to format lib/modules/score_timer.dart.)
  • lib/utils/areaeffectcloud.dart (Run dartfmt to format lib/utils/areaeffectcloud.dart.)
  • lib/utils/armorstand.dart (Run dartfmt to format lib/utils/armorstand.dart.)
  • lib/utils/aroundlocation.dart (Run dartfmt to format lib/utils/aroundlocation.dart.)
  • lib/utils/foreach.dart (Run dartfmt to format lib/utils/foreach.dart.)
  • lib/utils/log.dart (Run dartfmt to format lib/utils/log.dart.)
  • lib/utils/randomScore.dart (Run dartfmt to format lib/utils/randomScore.dart.)
  • lib/utils/raycast.dart (Run dartfmt to format lib/utils/raycast.dart.)
  • lib/utils/repeat.dart (Run dartfmt to format lib/utils/repeat.dart.)
  • lib/wrappers/advancement.dart (Run dartfmt to format lib/wrappers/advancement.dart.)
  • lib/wrappers/bossbar.dart (Run dartfmt to format lib/wrappers/bossbar.dart.)
  • lib/wrappers/clear.dart (Run dartfmt to format lib/wrappers/clear.dart.)
  • lib/wrappers/comment.dart (Run dartfmt to format lib/wrappers/comment.dart.)
  • lib/wrappers/effect.dart (Run dartfmt to format lib/wrappers/effect.dart.)
  • lib/wrappers/give.dart (Run dartfmt to format lib/wrappers/give.dart.)
  • lib/wrappers/kill.dart (Run dartfmt to format lib/wrappers/kill.dart.)
  • lib/wrappers/particle.dart (Run dartfmt to format lib/wrappers/particle.dart.)
  • lib/wrappers/schedule.dart (Run dartfmt to format lib/wrappers/schedule.dart.)
  • lib/wrappers/setblock.dart (Run dartfmt to format lib/wrappers/setblock.dart.)
  • lib/wrappers/summon.dart (Run dartfmt to format lib/wrappers/summon.dart.)
  • lib/wrappers/tellraw.dart (Run dartfmt to format lib/wrappers/tellraw.dart.)
  • lib/wrappers/title.dart (Run dartfmt to format lib/wrappers/title.dart.)
  • lib/wrappers/widgets.dart (Run dartfmt to format lib/wrappers/widgets.dart.)

Maintenance issues and suggestions

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field https://stevertus.com/objD was unreachable.

Documentation URL doesn't exist. (-10 points)

At the time of the analysis the documentation field https://stevertus.com/objD/documentation was unreachable.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
colorize ^2.0.0 2.0.0
meta ^1.1.7 1.1.7
path ^1.6.2 1.6.2
watcher ^0.9.7+10 0.9.7+12
Transitive dependencies
async 2.3.0
collection 1.14.11
pedantic 1.8.0+1

Admin