Skip to content

Instantly share code, notes, and snippets.

@intsuc
intsuc / explicit-1-if.mcfunction
Last active August 22, 2019 15:07
if statement with an implicit/explicit stack
execute if score #condition boolean matches 1 run function explicit-1-then
# peek
execute store result score #condition boolean run data get entity @s HandItems[0].tag.boolean_stack[-1]
execute if score #condition boolean matches 0 run function explicit-1-else
@intsuc
intsuc / init.mcfunction
Last active August 22, 2019 15:13
getblock loader
scoreboard objectives add loader dummy
@intsuc
intsuc / init.mcfunction
Last active August 22, 2019 15:13
5x5 forceload chunk loader (1.14.4)
scoreboard objectives add forceloader dummy
@intsuc
intsuc / init.mcfunction
Last active August 22, 2019 15:13
typeof function
scoreboard objectives add typeof dummy
# n @ data get block 0 0 0 RecordItem.tag.tags[n][0] | result
# ----------------------------------------------------------------------------+-------
# 0 (1b) | 1
# 1 (2s) | 2
# 2 (3) | 3
# 3 (4L) | 4
# 4 (5.0f) | 5
# 5 (6.0d) | 6
@intsuc
intsuc / init.mcfunction
Last active August 22, 2019 15:24
forceload chunk loader (1.14.4)
scoreboard objectives add _ dummy
@intsuc
intsuc / doc.md
Last active August 22, 2019 15:25
usercache map (non-username string -> UUID string)
  • Any entities that extend TameableEntity or AbstractHorseEntity works.

  • To jump to the else branch that performs the lookup:

    • HandItems[0].tag.OwnerUUID must not be TAG_String.
    • HandItems[0].tag.OwnerUUID and HandItems[0].tag.Owner must be assigned to the entity together.
String uuid;
if (tag.containsKey("OwnerUUID", TAG_String) /* This method returns false if an actual tag type is different from the specified type */) {
 uuid = tag.getString("OwnerUUID");
@intsuc
intsuc / init.mcfunction
Last active September 18, 2019 12:29
dimension chunk loader
execute in minecraft:the_nether run forceload add 0 0
kill @e[tag=removed, predicate=removable]
# the_nether
execute in minecraft:the_nether as @e[distance=0.0.., tag=removed] in minecraft:overworld run teleport @s 8.0 0.0 8.0
execute in minecraft:overworld as @e[x=7.5, y=-0.5, z=7.5, dx=0, tag=removed] in minecraft:the_nether run teleport @s 34359738360.0 0.0 34359738360.0
# overworld
execute in minecraft:overworld as @e[distance=0.0.., tag=removed] in minecraft:the_end run teleport @s 8.0 0.0 8.0
execute in minecraft:the_end as @e[x=7.5, y=-0.5, z=7.5, dx=0, tag=removed] in minecraft:overworld run teleport @s 34359738360.0 0.0 34359738360.0
# Passenger must be `LivingEntity`
summon minecraft:armor_stand 8.0 0.0 8.0 {Tags: ["vehicle"], Passengers: [{id: "minecraft:armor_stand", Tags: ["passenger"]}]}
# Move passenger to the current world position
execute as @e[x=7.5, y=-0.5, z=7.5, dx=0.0, tag=passenger] run function move_passenger
# Eject passenger
kill @e[x=7.5, y=-0.5, z=7.5, dx=0.0, tag=vehicle]