Giter Site home page Giter Site logo

ayfri / kore Goto Github PK

View Code? Open in Web Editor NEW
59.0 1.0 3.0 3.55 MB

A Kotlin library to generate Datapacks for Minecraft Java.

Home Page: https://kore.ayfri.com

License: GNU General Public License v3.0

Kotlin 100.00%
kotlin-dsl minecraft datapack kore functions minecraft-datapack minecraft-kotlin modding modding-tools

kore's Introduction

Kore

A Kotlin library to write Datapacks for Minecraft.

Stars GitHub GitHub issues GitHub closed issues Maven Central Kotlin Slack


kore typography

This library is compatible and made for Minecraft Java 1.20 and later versions, I don't think I will support older versions nor Bedrock Edition.
You can still create your own fork and make it compatible with older versions.
I will accept pull requests for older versions on a separate branch.

Getting Started

Install the library with Gradle, with Kotlin DSL:

implementation("io.github.ayfri.kore:kore:VERSION")

Or with Groovy DSL:

implementation 'io.github.ayfri.kore:kore:VERSION'

Then activate the -Xcontext-receivers compiler option:

kotlin {
	compilerOptions {
		freeCompilerArgs.add("-Xcontext-receivers")
	}
}

You should also use Java 17 or higher:

kotlin {
	jvmToolchain(17)
}

Then create a Main.kt file and start writing your datapacks. See the documentation for more information.

Example

fun main() {
	val datapack = dataPack("test") {
		function("display_text") {
			tellraw(allPlayers(), textComponent("Hello World!"))
		}

		recipes {
			craftingShaped("enchanted_golden_apple") {
				pattern(
					"GGG",
					"GAG",
					"GGG"
				)

				key("G", Items.GOLD_BLOCK)
				key("A", Items.APPLE)

				result(Items.ENCHANTED_GOLDEN_APPLE)
			}
		}

		function("tp_random_entity_to_entity") {
			val entityName = "test"
			val entity = allEntities(limitToOne = true) {
				name = entityName
			}

			summon(Entities.CREEPER, vec3(), nbt {
				this["CustomName"] = textComponent("Hello World!")
			})

			execute {
				asTarget(allEntities {
					limit = 3
					sort = Sort.RANDOM
				})

				ifCondition {
					score(self(), "test") lessThan 10
				}

				run {
					teleport(entity)
				}
			}
		}

		pack {
			description = textComponent("Datapack test for ", Color.GOLD) + text("Kore", Color.AQUA) { bold = true }
		}
	}

	datapack.generateZip()
}

Community Creations

Features

  • DataPack generation.
  • Function generation.
  • All commands with all subcommands and multiple syntaxes.
  • Generation of all JSON-based features of Minecraft (Advancements, Loot Tables, Recipes, ...).
  • Selectors.
  • NBT tags.
  • Chat components.
  • Lists for all registries (Blocks, Items, Entities, Advancements, ...).
  • Colors/Vector/Rotation/... classes with common operations.
  • Macros support.
  • Inventory/Scheduler managers.
  • Scoreboard display manager (like on servers).
  • Debugging system inside commands or functions.
  • Common Nbt tags generation (blocks, items, entities, ...).
  • OOP module (experimental).

Note: All APIs for commands, selectors, NBT tags, ... are public, so you can use them to create your own features.

Contributing

If you want to contribute to this project, you can follow these steps:

  1. Fork the repository.
  2. Run gradle kore:run to run the tests.
  3. Make your changes.
  4. Create a pull request and wait for it to be reviewed and merged.

You can also create an issue if you find a bug or if you want to suggest a new feature.

Support

If you want to support the project, please consider donating !

Buy Me A Coffee

License

This project is licensed under the GNU 3.0 License โ€“ see the LICENSE file for details.

kore's People

Contributors

augustinmauroy avatar ayfri avatar benwoodworth avatar imgbotapp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

kore's Issues

[BUG] Inappropriate argument in setEnchantments item modifier builder

Library version

1.0.0

What module does this bug apply to?

DSL

What happened?

I tried to use setEnchantments item modifier with its builder, but when i tried to add an enchantment to it I noticed that I cant do it. I looked at the source code and seen that in second parameter of function there is a Map instead of MutableMap and because of that it's impossible to add any enchantments.
image

How can we reproduce this issue?

  1. Create an item modifier
  2. Try to add setEnchantments item modifier to it
  3. Notice that you cant put any enchantments to the map of enchants

Extra information

No response

My issue is not duplicated

  • This is not a duplicate

Use block parameter syntax for all generators requiring one element from a list.

For example, DensityFunctions are currently created with the following code:

densityFunction("my_density_function", abs(2.0))

It will be refactored as this:

densityFunction("my_density_function") {
    abs(2.0)
}

Maybe investigate if it should throw an error if multiple functions for setting the type are used.

This will allow namespaces to be use simpler as every parameter of the Generator are usable from the lambda.

Add exemples.

This will help a lot of people to understand the concepts of the library and how to use it.

Add documentation to DSL module.

Simple documentation being added on all methods/classes/properties/typealiases.
Serializers might not be documented if only meant to be used once.

Add unit tests.

Add unit tests for :

  • All commands
  • All features
  • Selectors
  • All helpers
  • Utility classes like Color/Vec3

Update to 23w40a.

  • Add Chat Components type optional enum property.
  • Change default datapack version to 19.
  • Make showEntity method of HoverEvent also accepts an array of Int as id parameter.

Update to 23w46a

  • Add new scoreboard subcommands changes.
  • Update Scoreboard Displays to use the new subcommands.

Add special methods for `particle` command.

This is needed because the particle command arguments can have different usage depending on the particle type you put.
Certain types of particles can even have different states.
This is considered as high priority as it means that the current DSL methods are not totally valid

Source : Fandom

Update to 23w31a

Add support for :

  • New commands
  • New commands options
  • Macros
  • Pack.mcmeta changes (multi-versionning)

APIs for all JSON-related features of Minecraft

The API will let you create all JSON-related features from Minecraft

  • Advancements
  • Biomes
  • Chat Types
  • Damage Types
  • Dimensions
  • Dimensions Types
  • Item Modifiers
  • Loot tables
  • Predicates
  • Recipes
  • Tags
  • Typed Tags (block/entities/items etc)
  • World generation :
    • Biomes
    • Configured Carvers
    • Configured Features
    • Density Functions
    • Flat World Presets
    • Noises
    • Noise Settings
    • Placed Features
    • Processor Lists
    • Structures
    • Structure Sets
    • Template Pools
    • World Presets

Typed tags are just a more strict way to create tags, where the folder of the tag file can only be from the list of tags Minecraft uses.

Mistake in README.md

What happened?

In the exemple code in README.md, the pack block is outside the datapack. After trying it, I seen that it shouldn't be here.

What should have happened?

The pack block should be in the datapck

How can we reproduce this issue?

Try the code in the exemple and see IDE errors

extra-info

No response

Update to 23w42a

  • Add source property to nbt chat component.
  • Add new jigsaw structure pool aliases feature.

Add inventory manager.

Being able to define a list of item stacks inside any container at any slot.
Maybe also adding a way to define a behavior when clicking on the item.

Update to 23w44a

  • Add a new overload without any parameters to tick step subcommand.
  • Add new return fail subcommand.

Update to 1.20.2-pre1

  • Deprecate to ERROR level execute if function and return run functions until they return.
  • Add new map decorations.
  • Update default datapack version to 18.

Update to 23w41a.

  • Add dust_plume particle type.
  • Change default datapack version to 20.
  • Reintroduce execute if function and return run commands.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.