Skip to content

Instantly share code, notes, and snippets.

View QUAM-12's full-sized avatar
🏠
Working from home

QUAM12 QUAM-12

🏠
Working from home
View GitHub Profile
@tryashtar
tryashtar / selectors.md
Last active September 10, 2024 12:38
Code analysis of target selectors

Requirements

Selector arguments can optionally have two requirements: requiring only players, and requiring only a single target. Here are some examples of arguments of each type:

  • Only players: /give <targets>
  • Only a single target: /damage <target>
  • Only a single player: /xp query <targets>
  • Any number of any entities: /kill <targets>

As is well-known, each selector type has default "implicit" arguments. All behavior below will be described in terms of these arguments, not the base selectors themselves.

  • @p, @a, and @r have an implicit type=player, and will fail to parse if given a different type.

1.20-pre1 vs 1.20-pre2

benchmark 1.20-pre1 1.20-pre2
baseline 263.479460184556 ± 55.44590623221055 [ns/op] 262.6772200457718 ± 55.05785493224197 [ns/op]
data_get_byte 433.98316762350913 ± 7.444825260824145 [ns/op] 391.87628185594724 ± 18.936628742014072 [ns/op]
data_get_byte_1 740.4393732769925 ± 20.93953249166631 [ns/op] 456.17101920010447 ± 8.630503299692144 [ns/op]
data_get_int 412.08435852317024 ± 4.056129450233465 [ns/op] 374.34500487014526 ± 2.435684193080521 [ns/op]
data_get_int_1 737.7503310023358 ± 13.85836437954026 [ns/op] 423.18244626398047 ± 1.329924149473285 [ns/op]
data_get_list_0 406.8077717359254 ± 13.273700931499596 [ns/op] 380.8705782109833 ± 18.39461975718555 [ns/op]
data remove storage _ _
data modify storage _ _[] set value 0
data remove storage _ a
data remove storage _ b
function ite
@intsuc
intsuc / .md
Created February 9, 2023 14:07

Benchmarks

  • summon-1.mcfunction
summon marker
kill @e
  • execute-1.mcfunction
execute summon marker run kill @e
@intsuc
intsuc / .md
Created December 1, 2022 15:58

Benchmarks

  • init.mcfunction
    data modify storage 0 0 set value {a: [], b: 0}
    
    data modify storage 1 0 set value {a: [0, 0], b: 0}
    data modify storage 1 0.a append from storage 1 0.a[]
    data modify storage 1 0.a append from storage 1 0.a[]
    data modify storage 1 0.a append from storage 1 0.a[]
@kennytv
kennytv / readme.md
Last active September 7, 2024 18:09
Signed Chat and Chat Types

Signed chat

This gist intends on clearing up some of the misinformation surrounding signed chat/the reporting feature Mojang has added to Minecraft 1.19.1. Here you can find both technical information as well as a general explanation of how these work.

Profile keys

After joining a server, clients now send a profile key used for verifying a message's authenticity. This key and thus the whole signing process is optional, but by default, servers enforce secure profiles for clients to send chat messages. Whenever the player sends a chat message and has a key associated, the message will be signed using their own private key, which the server then verifies using the public key sent after join. Assuming signature, timestamp, and message contents line up, the message goes through.

On the other end, clients can also require all broadcasted player messages to be signed, disregarding the ones without sender verified signatures.

Message signatures

  • MinecraftServer::tickServer
    • ServerFunctionManager::tick
      • Run command functions
        • Trigger inventory_changed (loot, give, clear commands)
        • Trigger recipe_unlocked (recipe command)
        • Trigger effects_changed (effect command)
        • Trigger changed_dimension (teleport command)
    • ServerLevel::tick (per dimension)
      • ServerLevel::tickTime (overworld only)
  • Increment game time

Minecraft commands benchmarks

Each test ranks a list of possible commands from best (most efficient) to worst (least efficient). Lower percentages are better. You can only compare the percentages between the commands in the same test.

These tests were done in a superflat world with no entities except for the player. The only commands running are the ones from the test.

1 Running commands for every player

1.1 All players

tick
commandFunctions
minecraft:tick -> (Server)
minecraft:load -> (Server)
levels
$level
timeSync
tick
world border
weather