Skip to content

Instantly share code, notes, and snippets.

Optimizing and code-splitting

I decided to investigate the bundle size for misode.github.io and was quite shocked. After code splitting and tree shaking I managed to get the total JS output size from 5.22MB down to 3.95MB, and the main entrypoint from 4.53MB down to 703KB.

Initial bundle

The initial bundle was 5.22MB, with the main chunk 4.53MB (the red part). The only chunks split up were the different languages localizations. image

Remove unused highlight.js languages

One of the first things I noticed was that highlight.js included a bunch of languages, while I'm only using JSON. This eliminated 1.35MB. image

Custom data pack structures in 1.18.2

This guide will showcase how to create a data pack that adds a custom structure to the world. There is also a data pack download of this complete example.

Always leave the world and rejoin to apply the new changes!

⚠️ This guide has moved ⚠️

Updates for both 1.18.2 and 1.19 can be found at https://misode.github.io/guides/adding-custom-structures/

Pack.mcmeta

@misode
misode / full_noise.jsonc
Last active February 16, 2022 23:09
Density functions in 22w07a
{
"type": "min",
"input_1": {
"type": "squeeze",
"input": {
"type": "mul",
"input_1": {
"type": "interpolated",
"input": {
"type": "blend",
PROPS = {
"instrument": [
"harp",
"basedrum",
"snare",
"hat",
"bass",
"flute",
"bell",
"guitar",

Loot Context

Uses

Functions

  • looting_enchant: killer_entity
  • set_name only if entity is set: this_entity, killer_entity, direct_killer_entity, or last_damage_player
  • exploration_map: origin
  • copy_name depending on the value of source: this_entity, killer_entity, last_damage_player, or block_entity
  • apply_bonus: tool

command | Added the /jfr command, along with the --jfrProfile startup option

text font | Added illageralt rule-like font from Minecraft Dungeons

loot item-modifier | The set_contents and set_loot_table functions now require a type field with a valid block entity type

pack-format | Data pack format has been increased to 8

command scoreboard | Removed length limits for scoreboard objectives, score holders (fake players), and team names

@misode
misode / WorldgenExporter.java
Created August 10, 2021 23:44
Fabric mod using Mojang mappings to export worldgen settings, only tested on the 1.18 experimental snapshots.
package net.misode.worldgenexporter;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.mojang.serialization.Codec;
import com.mojang.serialization.DynamicOps;
import com.mojang.serialization.JsonOps;
import net.fabricmc.api.ModInitializer;
key.jump
key.sneak
key.sprint
key.left
key.right
key.back
key.forward
key.attack
key.pickItem
key.use

Critical

  • MC-215946 Game fatally crashed while exploring chunks (PalettedContainer)
  • MC-197860 Deleting a custom dimension in a datapack deletes Nether and End
  • MC-202036 Adding a biome to a datapack shifts biome IDs in existing chunks

Missing features

  • MC-197128 If a custom biome uses multiple configured structure features of the same type, only one of them can generate
  • MC-186626 /weather not working in custom dimensions
  • MC-195717 Custom Dimensions JSON Requires Seed
  • MC-226687 Sea Level is assumed to be Y 63 in numerous parts of Minecraft

Quality of life

  • 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