Skip to content

Instantly share code, notes, and snippets.

The purpose of events is to have triggers without needing an advancement for it. This should go hand in hand with the current data driven files. We have been using advancements for a totally different reason than what they were intended for. And that's what we wanted to avoid from 1.13 onwards. A few advantages is they work for all entities, not only for players. They keep triggering, so you don't need to revoke the advancement.

Events are json files put in namespace/data/events Its structure is very similar to the current advancement structure of a criteria.

Event structure

This event would run namespace:foo for every zombie that hurts a player in a plains biome

{
  "event": {

Loot syntax

/loot can be separated into two major parts, target and source. Those two parts follow each other in the command. In snapshots prior to 18w45a, this command was named /drop

loot <target> <source>

Last updated: 18w45a

Target

The target defines where to drop the items. It has several arguments. The first argument is the target type. It's one of these options: spawn, replace, insert and give.

Creating custom items with a datapack and resourcepack

Creating the texture

Orbis 1.13 Technical Details

Orbis works by scanning chunks and performing actions based on certain features of that chunk, like its biome, terrain height and specific blocks in the world. All conditions are based on world generation to make sure everything is seed deterministic.

orbis:main

Every 16 ticks, Orbis does a few things.

  • If a player with the gm4_orbis_active tag is in a chunk that has bedrock at y=0, it spawns a marker for that chunk, if there wasn't one already.
  • For every player with the gm4_orbis_active tag, it generates the closest chunk that hasn't been generated yet. This calls the orbis:chunk/generate function.
  • Kill every chunk that has been generated, but only if all four adjacent chunks have also been generated. This is because chunks use the biome of adjacent chunks to determine the final biome decision.

orbis:chunk/scan

Calculating the sqrt of a number

This method for calculating the square root uses an iterative algorithm known as the Babylonian method.

You need to run some commands once (or on every /reload).

scoreboard objectives add const dummy
scoreboard players set 2 const 2

scoreboard objectives add sqrt dummy

Preventing Fall Damage

This method is based on PingiPuck's video

You need to run a command once (or on every /reload).

scoreboard objectives add falling minecraft.custom:minecraft.time_since_death 

You need to run these commands for every player every tick

@misode
misode / events.md
Last active October 10, 2019 19:52

General Structure

{
  "trigger": string // one of the triggers mentioned below
  "predicate": {
    // trigger-specific properties
  },
  "actions": [
    {
 "action": string // one of "function", "advancement", ...
# Copy the last stone slot to a temp array
data modify storage temp Items[] set from block ~ ~ ~ Items[{id:"minecraft:stone"}]
# get the count in a scoreboard and remove one
execute store result storage temp Items[0].Count byte 1 run data get storage temp Items[0].Count 0.99
# Copy the last slot to the output items
data modify block ~ ~ ~ Items append from storage temp Items[0]
{
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": [
"source.mcfunction",
"string.unquoted.mcfunction"
],
"settings": {
"foreground": "#bbbbbb"
## 1.11
https://www.mojang.com/2016/09/minecraft-snapshot-16w35a/
https://www.mojang.com/2016/09/minecraft-snapshot-16w36a/
https://www.mojang.com/2016/09/minecraft-snapshot-16w38a/
https://www.mojang.com/2016/09/minecraft-snapshot-16w39a-the-exploration-update/
https://www.mojang.com/2016/10/minecraft-snapshot-16w40a/
https://www.mojang.com/2016/10/minecraft-snapshot-16w41a/
https://www.mojang.com/2016/10/minecraft-snapshot-16w42a/
https://www.mojang.com/2016/10/minecraft-snapshot-16w43a/
https://www.mojang.com/2016/11/seek-out-the-exploration-update-111-on-pc-mac-now/