Skip to content

Instantly share code, notes, and snippets.

@Arcensoth
Arcensoth / !README.md
Last active Dec 23, 2019
Iterating over NBT lists using functions
View !README.md
View linguist-language-mcfunction-results.txt
bundle exec bin/github-linguist language-mcfunction/ --breakdown
88.58% mcfunction
11.42% TypeScript
TypeScript:
build/build.ts
mcfunction:
tests/block_predicate.mcfunction
tests/coordinate.mcfunction
View binary_tags.py
import json
import math
import sys
import os
infile = os.path.abspath(sys.argv[1])
outdir = os.path.abspath(sys.argv[2] if len(sys.argv) > 2 else '.')
factor = int(sys.argv[3]) if len(sys.argv) > 3 else 2
View chest.snbt
{
Items: [{
Slot: 0b,
id: "minecraft:gunpowder",
Count: 6 b
}, {
Slot: 4 b,
id: "minecraft:bucket",
Count: 1 b
}, {
View horse.snbt
{
HurtByTimestamp: 0,
Tame: 0b,
Attributes: [{
Base: 17.0 d,
Name: "generic.maxHealth"
}, {
Base: 0.0 d,
Name: "generic.knockbackResistance"
}, {
View minecraft_command_generation.md

Minecraft command generation

This is a proposition on using Python to dynamically generate commands, which is useful for things like function trees, repetitive code, and/or any large-scale projects.

Preface

Most of the code blocks presented are just snippets that don't do anything useful on their own. The idea is that the commented line is the command you'd expect to see by printing the object that follows.

Here's a classic example:

# say hi
commands.say(message='hi')
View damage.md

Direct

Source Flags
anvil
cactus
cramming bypasses_armor
dragonBreath bypasses_armor
drown bypasses_armor
fall bypasses_armor
fallingBlock
View LootTableSeed.json
{
"tag": "LootTableSeed",
"type": "long",
"optional": true,
"summary": "Seed to generate the loot table.",
"details": [
"A set seed that can be used to produce consistent results from the given "
{ "text": "loot table", "reference": "Entity.LootTable" },
", if any. The same seed will result in the same loot, every time."
],
View playsounds.txt
ambient.cave
ambient.underwater.loop
ambient.underwater.loop.additions
ambient.underwater.loop.additions.rare
ambient.underwater.loop.additions.ultrarare
ambient.underwater.enter
ambient.underwater.exit
block.anvil.break
block.anvil.destroy
block.anvil.fall
View findandreplace.py
import os
import sys
dirpath = sys.argv[1]
oldtext = sys.argv[2]
newtext = sys.argv[3]
for root, subdirs, files in os.walk(dirpath):
for filename in files: