diff --git a/examples/frameworkServer/Dimension.snbt b/examples/frameworkServer/Dimension.snbt deleted file mode 100644 index 2b9092d..0000000 --- a/examples/frameworkServer/Dimension.snbt +++ /dev/null @@ -1,17 +0,0 @@ -{ - piglin_safe: 0b, - natural: 1b, - ambient_light: 0.0f, - infiniburn: "minecraft:infiniburn_overworld", - respawn_anchor_works: 0b, - has_skylight: 1b, - bed_works: 1b, - effects: "minecraft:overworld", - has_raids: 1b, - min_y: 0, - height: 256, - logical_height: 256, - coordinate_scale: 1.0d, - ultrawarm: 0b, - has_ceiling: 0b -} \ No newline at end of file diff --git a/examples/frameworkServer/DimensionCodec.snbt b/examples/frameworkServer/DimensionCodec.snbt deleted file mode 100644 index 69072ab..0000000 --- a/examples/frameworkServer/DimensionCodec.snbt +++ /dev/null @@ -1,2093 +0,0 @@ -{ - "minecraft:dimension_type": { - type: "minecraft:dimension_type", - value: [ - { - name: "minecraft:overworld", - id: 0, - element: { - piglin_safe: 0b, - natural: 1b, - ambient_light: 0.0f, - infiniburn: "minecraft:infiniburn_overworld", - respawn_anchor_works: 0b, - has_skylight: 1b, - bed_works: 1b, - effects: "minecraft:overworld", - has_raids: 1b, - min_y: 0, - height: 256, - logical_height: 256, - coordinate_scale: 1.0d, - ultrawarm: 0b, - has_ceiling: 0b - } - }, - { - name: "minecraft:overworld_caves", - id: 1, - element: { - piglin_safe: 0b, - natural: 1b, - ambient_light: 0.0f, - infiniburn: "minecraft:infiniburn_overworld", - respawn_anchor_works: 0b, - has_skylight: 1b, - bed_works: 1b, - effects: "minecraft:overworld", - has_raids: 1b, - min_y: 0, - height: 256, - logical_height: 256, - coordinate_scale: 1.0d, - ultrawarm: 0b, - has_ceiling: 1b - } - }, - { - name: "minecraft:the_nether", - id: 2, - element: { - piglin_safe: 1b, - natural: 0b, - ambient_light: 0.1f, - infiniburn: "minecraft:infiniburn_nether", - respawn_anchor_works: 1b, - has_skylight: 0b, - bed_works: 0b, - effects: "minecraft:the_nether", - fixed_time: 18000L, - has_raids: 0b, - min_y: 0, - height: 256, - logical_height: 128, - coordinate_scale: 8.0d, - ultrawarm: 1b, - has_ceiling: 1b - } - }, - { - name: "minecraft:the_end", - id: 3, - element: { - piglin_safe: 0b, - natural: 0b, - ambient_light: 0.0f, - infiniburn: "minecraft:infiniburn_end", - respawn_anchor_works: 0b, - has_skylight: 0b, - bed_works: 0b, - effects: "minecraft:the_end", - fixed_time: 6000L, - has_raids: 1b, - min_y: 0, - height: 256, - logical_height: 256, - coordinate_scale: 1.0d, - ultrawarm: 0b, - has_ceiling: 0b - } - } - ] - }, - "minecraft:worldgen/biome": { - type: "minecraft:worldgen/biome", - value: [ - { - name: "minecraft:ocean", - id: 0, - element: { - precipitation: "rain", - effects: { - sky_color: 8103167, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: -1.0f, - temperature: 0.5f, - scale: 0.1f, - downfall: 0.5f, - category: "ocean" - } - }, - { - name: "minecraft:plains", - id: 1, - element: { - precipitation: "rain", - effects: { - sky_color: 7907327, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.125f, - temperature: 0.8f, - scale: 0.05f, - downfall: 0.4f, - category: "plains" - } - }, - { - name: "minecraft:desert", - id: 2, - element: { - precipitation: "none", - effects: { - sky_color: 7254527, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.125f, - temperature: 2.0f, - scale: 0.05f, - downfall: 0.0f, - category: "desert" - } - }, - { - name: "minecraft:mountains", - id: 3, - element: { - precipitation: "rain", - effects: { - sky_color: 8233727, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 1.0f, - temperature: 0.2f, - scale: 0.5f, - downfall: 0.3f, - category: "extreme_hills" - } - }, - { - name: "minecraft:forest", - id: 4, - element: { - precipitation: "rain", - effects: { - sky_color: 7972607, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 0.7f, - scale: 0.2f, - downfall: 0.8f, - category: "forest" - } - }, - { - name: "minecraft:taiga", - id: 5, - element: { - precipitation: "rain", - effects: { - sky_color: 8233983, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.2f, - temperature: 0.25f, - scale: 0.2f, - downfall: 0.8f, - category: "taiga" - } - }, - { - name: "minecraft:swamp", - id: 6, - element: { - precipitation: "rain", - effects: { - grass_color_modifier: "swamp", - sky_color: 7907327, - foliage_color: 6975545, - water_fog_color: 2302743, - fog_color: 12638463, - water_color: 6388580, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: -0.2f, - temperature: 0.8f, - scale: 0.1f, - downfall: 0.9f, - category: "swamp" - } - }, - { - name: "minecraft:river", - id: 7, - element: { - precipitation: "rain", - effects: { - sky_color: 8103167, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: -0.5f, - temperature: 0.5f, - scale: 0.0f, - downfall: 0.5f, - category: "river" - } - }, - { - name: "minecraft:nether_wastes", - id: 8, - element: { - precipitation: "none", - effects: { - music: { - replace_current_music: 0b, - max_delay: 24000, - sound: "minecraft:music.nether.nether_wastes", - min_delay: 12000 - }, - sky_color: 7254527, - ambient_sound: "minecraft:ambient.nether_wastes.loop", - additions_sound: { - sound: "minecraft:ambient.nether_wastes.additions", - tick_chance: 0.0111d - }, - water_fog_color: 329011, - fog_color: 3344392, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.nether_wastes.mood", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 2.0f, - scale: 0.2f, - downfall: 0.0f, - category: "nether" - } - }, - { - name: "minecraft:the_end", - id: 9, - element: { - precipitation: "none", - effects: { - sky_color: 0, - water_fog_color: 329011, - fog_color: 10518688, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 0.5f, - scale: 0.2f, - downfall: 0.5f, - category: "the_end" - } - }, - { - name: "minecraft:frozen_ocean", - id: 10, - element: { - precipitation: "snow", - effects: { - sky_color: 8364543, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 3750089, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: -1.0f, - temperature: 0.0f, - scale: 0.1f, - downfall: 0.5f, - category: "ocean", - temperature_modifier: "frozen" - } - }, - { - name: "minecraft:frozen_river", - id: 11, - element: { - precipitation: "snow", - effects: { - sky_color: 8364543, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 3750089, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: -0.5f, - temperature: 0.0f, - scale: 0.0f, - downfall: 0.5f, - category: "river" - } - }, - { - name: "minecraft:snowy_tundra", - id: 12, - element: { - precipitation: "snow", - effects: { - sky_color: 8364543, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.125f, - temperature: 0.0f, - scale: 0.05f, - downfall: 0.5f, - category: "icy" - } - }, - { - name: "minecraft:snowy_mountains", - id: 13, - element: { - precipitation: "snow", - effects: { - sky_color: 8364543, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.45f, - temperature: 0.0f, - scale: 0.3f, - downfall: 0.5f, - category: "icy" - } - }, - { - name: "minecraft:mushroom_fields", - id: 14, - element: { - precipitation: "rain", - effects: { - sky_color: 7842047, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.2f, - temperature: 0.9f, - scale: 0.3f, - downfall: 1.0f, - category: "mushroom" - } - }, - { - name: "minecraft:mushroom_field_shore", - id: 15, - element: { - precipitation: "rain", - effects: { - sky_color: 7842047, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.0f, - temperature: 0.9f, - scale: 0.025f, - downfall: 1.0f, - category: "mushroom" - } - }, - { - name: "minecraft:beach", - id: 16, - element: { - precipitation: "rain", - effects: { - sky_color: 7907327, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.0f, - temperature: 0.8f, - scale: 0.025f, - downfall: 0.4f, - category: "beach" - } - }, - { - name: "minecraft:desert_hills", - id: 17, - element: { - precipitation: "none", - effects: { - sky_color: 7254527, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.45f, - temperature: 2.0f, - scale: 0.3f, - downfall: 0.0f, - category: "desert" - } - }, - { - name: "minecraft:wooded_hills", - id: 18, - element: { - precipitation: "rain", - effects: { - sky_color: 7972607, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.45f, - temperature: 0.7f, - scale: 0.3f, - downfall: 0.8f, - category: "forest" - } - }, - { - name: "minecraft:taiga_hills", - id: 19, - element: { - precipitation: "rain", - effects: { - sky_color: 8233983, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.45f, - temperature: 0.25f, - scale: 0.3f, - downfall: 0.8f, - category: "taiga" - } - }, - { - name: "minecraft:mountain_edge", - id: 20, - element: { - precipitation: "rain", - effects: { - sky_color: 8233727, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.8f, - temperature: 0.2f, - scale: 0.3f, - downfall: 0.3f, - category: "extreme_hills" - } - }, - { - name: "minecraft:jungle", - id: 21, - element: { - precipitation: "rain", - effects: { - sky_color: 7842047, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 0.95f, - scale: 0.2f, - downfall: 0.9f, - category: "jungle" - } - }, - { - name: "minecraft:jungle_hills", - id: 22, - element: { - precipitation: "rain", - effects: { - sky_color: 7842047, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.45f, - temperature: 0.95f, - scale: 0.3f, - downfall: 0.9f, - category: "jungle" - } - }, - { - name: "minecraft:jungle_edge", - id: 23, - element: { - precipitation: "rain", - effects: { - sky_color: 7842047, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 0.95f, - scale: 0.2f, - downfall: 0.8f, - category: "jungle" - } - }, - { - name: "minecraft:deep_ocean", - id: 24, - element: { - precipitation: "rain", - effects: { - sky_color: 8103167, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: -1.8f, - temperature: 0.5f, - scale: 0.1f, - downfall: 0.5f, - category: "ocean" - } - }, - { - name: "minecraft:stone_shore", - id: 25, - element: { - precipitation: "rain", - effects: { - sky_color: 8233727, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 0.2f, - scale: 0.8f, - downfall: 0.3f, - category: "none" - } - }, - { - name: "minecraft:snowy_beach", - id: 26, - element: { - precipitation: "snow", - effects: { - sky_color: 8364543, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4020182, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.0f, - temperature: 0.05f, - scale: 0.025f, - downfall: 0.3f, - category: "beach" - } - }, - { - name: "minecraft:birch_forest", - id: 27, - element: { - precipitation: "rain", - effects: { - sky_color: 8037887, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 0.6f, - scale: 0.2f, - downfall: 0.6f, - category: "forest" - } - }, - { - name: "minecraft:birch_forest_hills", - id: 28, - element: { - precipitation: "rain", - effects: { - sky_color: 8037887, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.45f, - temperature: 0.6f, - scale: 0.3f, - downfall: 0.6f, - category: "forest" - } - }, - { - name: "minecraft:dark_forest", - id: 29, - element: { - precipitation: "rain", - effects: { - grass_color_modifier: "dark_forest", - sky_color: 7972607, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 0.7f, - scale: 0.2f, - downfall: 0.8f, - category: "forest" - } - }, - { - name: "minecraft:snowy_taiga", - id: 30, - element: { - precipitation: "snow", - effects: { - sky_color: 8625919, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4020182, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.2f, - temperature: -0.5f, - scale: 0.2f, - downfall: 0.4f, - category: "taiga" - } - }, - { - name: "minecraft:snowy_taiga_hills", - id: 31, - element: { - precipitation: "snow", - effects: { - sky_color: 8625919, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4020182, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.45f, - temperature: -0.5f, - scale: 0.3f, - downfall: 0.4f, - category: "taiga" - } - }, - { - name: "minecraft:giant_tree_taiga", - id: 32, - element: { - precipitation: "rain", - effects: { - sky_color: 8168447, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.2f, - temperature: 0.3f, - scale: 0.2f, - downfall: 0.8f, - category: "taiga" - } - }, - { - name: "minecraft:giant_tree_taiga_hills", - id: 33, - element: { - precipitation: "rain", - effects: { - sky_color: 8168447, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.45f, - temperature: 0.3f, - scale: 0.3f, - downfall: 0.8f, - category: "taiga" - } - }, - { - name: "minecraft:wooded_mountains", - id: 34, - element: { - precipitation: "rain", - effects: { - sky_color: 8233727, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 1.0f, - temperature: 0.2f, - scale: 0.5f, - downfall: 0.3f, - category: "extreme_hills" - } - }, - { - name: "minecraft:savanna", - id: 35, - element: { - precipitation: "none", - effects: { - sky_color: 7711487, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.125f, - temperature: 1.2f, - scale: 0.05f, - downfall: 0.0f, - category: "savanna" - } - }, - { - name: "minecraft:savanna_plateau", - id: 36, - element: { - precipitation: "none", - effects: { - sky_color: 7776511, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 1.5f, - temperature: 1.0f, - scale: 0.025f, - downfall: 0.0f, - category: "savanna" - } - }, - { - name: "minecraft:badlands", - id: 37, - element: { - precipitation: "none", - effects: { - sky_color: 7254527, - grass_color: 9470285, - foliage_color: 10387789, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 2.0f, - scale: 0.2f, - downfall: 0.0f, - category: "mesa" - } - }, - { - name: "minecraft:wooded_badlands_plateau", - id: 38, - element: { - precipitation: "none", - effects: { - sky_color: 7254527, - grass_color: 9470285, - foliage_color: 10387789, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 1.5f, - temperature: 2.0f, - scale: 0.025f, - downfall: 0.0f, - category: "mesa" - } - }, - { - name: "minecraft:badlands_plateau", - id: 39, - element: { - precipitation: "none", - effects: { - sky_color: 7254527, - grass_color: 9470285, - foliage_color: 10387789, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 1.5f, - temperature: 2.0f, - scale: 0.025f, - downfall: 0.0f, - category: "mesa" - } - }, - { - name: "minecraft:small_end_islands", - id: 40, - element: { - precipitation: "none", - effects: { - sky_color: 0, - water_fog_color: 329011, - fog_color: 10518688, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 0.5f, - scale: 0.2f, - downfall: 0.5f, - category: "the_end" - } - }, - { - name: "minecraft:end_midlands", - id: 41, - element: { - precipitation: "none", - effects: { - sky_color: 0, - water_fog_color: 329011, - fog_color: 10518688, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 0.5f, - scale: 0.2f, - downfall: 0.5f, - category: "the_end" - } - }, - { - name: "minecraft:end_highlands", - id: 42, - element: { - precipitation: "none", - effects: { - sky_color: 0, - water_fog_color: 329011, - fog_color: 10518688, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 0.5f, - scale: 0.2f, - downfall: 0.5f, - category: "the_end" - } - }, - { - name: "minecraft:end_barrens", - id: 43, - element: { - precipitation: "none", - effects: { - sky_color: 0, - water_fog_color: 329011, - fog_color: 10518688, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 0.5f, - scale: 0.2f, - downfall: 0.5f, - category: "the_end" - } - }, - { - name: "minecraft:warm_ocean", - id: 44, - element: { - precipitation: "rain", - effects: { - sky_color: 8103167, - water_fog_color: 270131, - fog_color: 12638463, - water_color: 4445678, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: -1.0f, - temperature: 0.5f, - scale: 0.1f, - downfall: 0.5f, - category: "ocean" - } - }, - { - name: "minecraft:lukewarm_ocean", - id: 45, - element: { - precipitation: "rain", - effects: { - sky_color: 8103167, - water_fog_color: 267827, - fog_color: 12638463, - water_color: 4566514, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: -1.0f, - temperature: 0.5f, - scale: 0.1f, - downfall: 0.5f, - category: "ocean" - } - }, - { - name: "minecraft:cold_ocean", - id: 46, - element: { - precipitation: "rain", - effects: { - sky_color: 8103167, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4020182, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: -1.0f, - temperature: 0.5f, - scale: 0.1f, - downfall: 0.5f, - category: "ocean" - } - }, - { - name: "minecraft:deep_warm_ocean", - id: 47, - element: { - precipitation: "rain", - effects: { - sky_color: 8103167, - water_fog_color: 270131, - fog_color: 12638463, - water_color: 4445678, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: -1.8f, - temperature: 0.5f, - scale: 0.1f, - downfall: 0.5f, - category: "ocean" - } - }, - { - name: "minecraft:deep_lukewarm_ocean", - id: 48, - element: { - precipitation: "rain", - effects: { - sky_color: 8103167, - water_fog_color: 267827, - fog_color: 12638463, - water_color: 4566514, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: -1.8f, - temperature: 0.5f, - scale: 0.1f, - downfall: 0.5f, - category: "ocean" - } - }, - { - name: "minecraft:deep_cold_ocean", - id: 49, - element: { - precipitation: "rain", - effects: { - sky_color: 8103167, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4020182, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: -1.8f, - temperature: 0.5f, - scale: 0.1f, - downfall: 0.5f, - category: "ocean" - } - }, - { - name: "minecraft:deep_frozen_ocean", - id: 50, - element: { - precipitation: "rain", - effects: { - sky_color: 8103167, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 3750089, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: -1.8f, - temperature: 0.5f, - scale: 0.1f, - downfall: 0.5f, - category: "ocean", - temperature_modifier: "frozen" - } - }, - { - name: "minecraft:the_void", - id: 127, - element: { - precipitation: "none", - effects: { - sky_color: 8103167, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 0.5f, - scale: 0.2f, - downfall: 0.5f, - category: "none" - } - }, - { - name: "minecraft:sunflower_plains", - id: 129, - element: { - precipitation: "rain", - effects: { - sky_color: 7907327, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.125f, - temperature: 0.8f, - scale: 0.05f, - downfall: 0.4f, - category: "plains" - } - }, - { - name: "minecraft:desert_lakes", - id: 130, - element: { - precipitation: "none", - effects: { - sky_color: 7254527, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.225f, - temperature: 2.0f, - scale: 0.25f, - downfall: 0.0f, - category: "desert" - } - }, - { - name: "minecraft:gravelly_mountains", - id: 131, - element: { - precipitation: "rain", - effects: { - sky_color: 8233727, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 1.0f, - temperature: 0.2f, - scale: 0.5f, - downfall: 0.3f, - category: "extreme_hills" - } - }, - { - name: "minecraft:flower_forest", - id: 132, - element: { - precipitation: "rain", - effects: { - sky_color: 7972607, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 0.7f, - scale: 0.4f, - downfall: 0.8f, - category: "forest" - } - }, - { - name: "minecraft:taiga_mountains", - id: 133, - element: { - precipitation: "rain", - effects: { - sky_color: 8233983, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.3f, - temperature: 0.25f, - scale: 0.4f, - downfall: 0.8f, - category: "taiga" - } - }, - { - name: "minecraft:swamp_hills", - id: 134, - element: { - precipitation: "rain", - effects: { - grass_color_modifier: "swamp", - sky_color: 7907327, - foliage_color: 6975545, - water_fog_color: 2302743, - fog_color: 12638463, - water_color: 6388580, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: -0.1f, - temperature: 0.8f, - scale: 0.3f, - downfall: 0.9f, - category: "swamp" - } - }, - { - name: "minecraft:ice_spikes", - id: 140, - element: { - precipitation: "snow", - effects: { - sky_color: 8364543, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.425f, - temperature: 0.0f, - scale: 0.45000002f, - downfall: 0.5f, - category: "icy" - } - }, - { - name: "minecraft:modified_jungle", - id: 149, - element: { - precipitation: "rain", - effects: { - sky_color: 7842047, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.2f, - temperature: 0.95f, - scale: 0.4f, - downfall: 0.9f, - category: "jungle" - } - }, - { - name: "minecraft:modified_jungle_edge", - id: 151, - element: { - precipitation: "rain", - effects: { - sky_color: 7842047, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.2f, - temperature: 0.95f, - scale: 0.4f, - downfall: 0.8f, - category: "jungle" - } - }, - { - name: "minecraft:tall_birch_forest", - id: 155, - element: { - precipitation: "rain", - effects: { - sky_color: 8037887, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.2f, - temperature: 0.6f, - scale: 0.4f, - downfall: 0.6f, - category: "forest" - } - }, - { - name: "minecraft:tall_birch_hills", - id: 156, - element: { - precipitation: "rain", - effects: { - sky_color: 8037887, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.55f, - temperature: 0.6f, - scale: 0.5f, - downfall: 0.6f, - category: "forest" - } - }, - { - name: "minecraft:dark_forest_hills", - id: 157, - element: { - precipitation: "rain", - effects: { - grass_color_modifier: "dark_forest", - sky_color: 7972607, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.2f, - temperature: 0.7f, - scale: 0.4f, - downfall: 0.8f, - category: "forest" - } - }, - { - name: "minecraft:snowy_taiga_mountains", - id: 158, - element: { - precipitation: "snow", - effects: { - sky_color: 8625919, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4020182, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.3f, - temperature: -0.5f, - scale: 0.4f, - downfall: 0.4f, - category: "taiga" - } - }, - { - name: "minecraft:giant_spruce_taiga", - id: 160, - element: { - precipitation: "rain", - effects: { - sky_color: 8233983, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.2f, - temperature: 0.25f, - scale: 0.2f, - downfall: 0.8f, - category: "taiga" - } - }, - { - name: "minecraft:giant_spruce_taiga_hills", - id: 161, - element: { - precipitation: "rain", - effects: { - sky_color: 8233983, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.2f, - temperature: 0.25f, - scale: 0.2f, - downfall: 0.8f, - category: "taiga" - } - }, - { - name: "minecraft:modified_gravelly_mountains", - id: 162, - element: { - precipitation: "rain", - effects: { - sky_color: 8233727, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 1.0f, - temperature: 0.2f, - scale: 0.5f, - downfall: 0.3f, - category: "extreme_hills" - } - }, - { - name: "minecraft:shattered_savanna", - id: 163, - element: { - precipitation: "none", - effects: { - sky_color: 7776767, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.3625f, - temperature: 1.1f, - scale: 1.225f, - downfall: 0.0f, - category: "savanna" - } - }, - { - name: "minecraft:shattered_savanna_plateau", - id: 164, - element: { - precipitation: "none", - effects: { - sky_color: 7776511, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 1.05f, - temperature: 1.0f, - scale: 1.2125001f, - downfall: 0.0f, - category: "savanna" - } - }, - { - name: "minecraft:eroded_badlands", - id: 165, - element: { - precipitation: "none", - effects: { - sky_color: 7254527, - grass_color: 9470285, - foliage_color: 10387789, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 2.0f, - scale: 0.2f, - downfall: 0.0f, - category: "mesa" - } - }, - { - name: "minecraft:modified_wooded_badlands_plateau", - id: 166, - element: { - precipitation: "none", - effects: { - sky_color: 7254527, - grass_color: 9470285, - foliage_color: 10387789, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.45f, - temperature: 2.0f, - scale: 0.3f, - downfall: 0.0f, - category: "mesa" - } - }, - { - name: "minecraft:modified_badlands_plateau", - id: 167, - element: { - precipitation: "none", - effects: { - sky_color: 7254527, - grass_color: 9470285, - foliage_color: 10387789, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.45f, - temperature: 2.0f, - scale: 0.3f, - downfall: 0.0f, - category: "mesa" - } - }, - { - name: "minecraft:bamboo_jungle", - id: 168, - element: { - precipitation: "rain", - effects: { - sky_color: 7842047, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 0.95f, - scale: 0.2f, - downfall: 0.9f, - category: "jungle" - } - }, - { - name: "minecraft:bamboo_jungle_hills", - id: 169, - element: { - precipitation: "rain", - effects: { - sky_color: 7842047, - water_fog_color: 329011, - fog_color: 12638463, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.cave", - block_search_extent: 8 - } - }, - depth: 0.45f, - temperature: 0.95f, - scale: 0.3f, - downfall: 0.9f, - category: "jungle" - } - }, - { - name: "minecraft:soul_sand_valley", - id: 170, - element: { - precipitation: "none", - effects: { - music: { - replace_current_music: 0b, - max_delay: 24000, - sound: "minecraft:music.nether.soul_sand_valley", - min_delay: 12000 - }, - sky_color: 7254527, - ambient_sound: "minecraft:ambient.soul_sand_valley.loop", - additions_sound: { - sound: "minecraft:ambient.soul_sand_valley.additions", - tick_chance: 0.0111d - }, - particle: { - probability: 0.00625f, - options: { - type: "minecraft:ash" - } - }, - water_fog_color: 329011, - fog_color: 1787717, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.soul_sand_valley.mood", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 2.0f, - scale: 0.2f, - downfall: 0.0f, - category: "nether" - } - }, - { - name: "minecraft:crimson_forest", - id: 171, - element: { - precipitation: "none", - effects: { - music: { - replace_current_music: 0b, - max_delay: 24000, - sound: "minecraft:music.nether.crimson_forest", - min_delay: 12000 - }, - sky_color: 7254527, - ambient_sound: "minecraft:ambient.crimson_forest.loop", - additions_sound: { - sound: "minecraft:ambient.crimson_forest.additions", - tick_chance: 0.0111d - }, - particle: { - probability: 0.025f, - options: { - type: "minecraft:crimson_spore" - } - }, - water_fog_color: 329011, - fog_color: 3343107, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.crimson_forest.mood", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 2.0f, - scale: 0.2f, - downfall: 0.0f, - category: "nether" - } - }, - { - name: "minecraft:warped_forest", - id: 172, - element: { - precipitation: "none", - effects: { - music: { - replace_current_music: 0b, - max_delay: 24000, - sound: "minecraft:music.nether.warped_forest", - min_delay: 12000 - }, - sky_color: 7254527, - ambient_sound: "minecraft:ambient.warped_forest.loop", - additions_sound: { - sound: "minecraft:ambient.warped_forest.additions", - tick_chance: 0.0111d - }, - particle: { - probability: 0.01428f, - options: { - type: "minecraft:warped_spore" - } - }, - water_fog_color: 329011, - fog_color: 1705242, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.warped_forest.mood", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 2.0f, - scale: 0.2f, - downfall: 0.0f, - category: "nether" - } - }, - { - name: "minecraft:basalt_deltas", - id: 173, - element: { - precipitation: "none", - effects: { - music: { - replace_current_music: 0b, - max_delay: 24000, - sound: "minecraft:music.nether.basalt_deltas", - min_delay: 12000 - }, - sky_color: 7254527, - ambient_sound: "minecraft:ambient.basalt_deltas.loop", - additions_sound: { - sound: "minecraft:ambient.basalt_deltas.additions", - tick_chance: 0.0111d - }, - particle: { - probability: 0.118093334f, - options: { - type: "minecraft:white_ash" - } - }, - water_fog_color: 4341314, - fog_color: 6840176, - water_color: 4159204, - mood_sound: { - tick_delay: 6000, - offset: 2.0d, - sound: "minecraft:ambient.basalt_deltas.mood", - block_search_extent: 8 - } - }, - depth: 0.1f, - temperature: 2.0f, - scale: 0.2f, - downfall: 0.0f, - category: "nether" - } - } - ] - } -} \ No newline at end of file diff --git a/examples/frameworkServer/main.go b/examples/frameworkServer/main.go index 246e36e..337c3dc 100644 --- a/examples/frameworkServer/main.go +++ b/examples/frameworkServer/main.go @@ -8,18 +8,9 @@ import ( "os" "github.com/Tnze/go-mc/chat" - "github.com/Tnze/go-mc/data/packetid" - "github.com/Tnze/go-mc/nbt" - "github.com/Tnze/go-mc/net" - pk "github.com/Tnze/go-mc/net/packet" "github.com/Tnze/go-mc/server" - "github.com/google/uuid" ) -type MyServer struct { - playerList *server.PlayerList -} - const MaxPlayer = 20 const IconPath = "./server-icon.png" @@ -31,61 +22,24 @@ func main() { if err != nil { log.Fatalf("Set server info error: %v", err) } - ms := MyServer{ - playerList: playerList, - } - + defaultDimension := server.NewSimpleDim(16) + defaultDimension.LoadChunk(server.ChunkPos{X: 0, Z: 0}, server.EmptyChunk(16)) s := server.Server{ ListPingHandler: serverInfo, LoginHandler: &server.MojangLoginHandler{ OnlineMode: true, Threshold: 256, }, - GamePlay: &ms, + GamePlay: &server.Game{ + Dim: defaultDimension, + PlayerList: playerList, + }, } if err := s.Listen(":25565"); err != nil { log.Fatalf("Listen error: %v", err) } } -func (m *MyServer) AcceptPlayer(name string, id uuid.UUID, protocol int32, conn *net.Conn) { - // Add player into PlayerList - remove := m.playerList.TryInsert(server.PlayerSample{ - Name: name, - ID: id, - }) - if remove == nil { - err := conn.WritePacket(pk.Marshal(packetid.ClientboundDisconnect, - chat.TranslateMsg("multiplayer.disconnect.server_full"), - )) - if err != nil { - log.Printf("Write packet fail: %v", err) - } - return - } - defer remove() - - if err := m.joinGame(conn); err != nil { - log.Printf("Write packet fail: %v", err) - return - } - if err := m.playerPositionAndLook(conn); err != nil { - log.Printf("Write packet fail: %v", err) - return - } - - var p pk.Packet - for { - err := conn.ReadPacket(&p) - if err != nil { - log.Printf("Read packet fail: %v", err) - break - } - - log.Printf("Read packet: %#X", p.ID) - } -} - func readIcon() image.Image { f, err := os.Open(IconPath) // if the file doesn't exist, return nil @@ -102,41 +56,3 @@ func readIcon() image.Image { } return icon } - -//go:embed DimensionCodec.snbt -var dimensionCodecSNBT string - -//go:embed Dimension.snbt -var dimensionSNBT string - -func (m *MyServer) joinGame(conn *net.Conn) error { - return conn.WritePacket(pk.Marshal(packetid.ClientboundLogin, - pk.Int(0), // EntityID - pk.Boolean(false), // Is hardcore - pk.UnsignedByte(1), // Gamemode - pk.Byte(1), // Previous Gamemode - pk.VarInt(1), // World Count - pk.Ary{Len: 1, Ary: []pk.Identifier{"world"}}, // World Names - pk.NBT(nbt.StringifiedMessage(dimensionCodecSNBT)), // Dimension codec - pk.NBT(nbt.StringifiedMessage(dimensionSNBT)), // Dimension - pk.Identifier("world"), // World Name - pk.Long(0), // Hashed Seed - pk.VarInt(MaxPlayer), // Max Players - pk.VarInt(15), // View Distance - pk.VarInt(15), // Simulation Distance - pk.Boolean(false), // Reduced Debug Info - pk.Boolean(true), // Enable respawn screen - pk.Boolean(false), // Is Debug - pk.Boolean(true), // Is Flat - )) -} - -func (m *MyServer) playerPositionAndLook(conn *net.Conn) error { - return conn.WritePacket(pk.Marshal(packetid.ClientboundPlayerPosition, - pk.Double(0), pk.Double(0), pk.Double(0), // XYZ - pk.Float(0), pk.Float(0), // Yaw Pitch - pk.Byte(0), // flag - pk.VarInt(0), // TP ID - pk.Boolean(false), // Dismount vehicle - )) -} diff --git a/save/bitstorage.go b/save/bitstorage.go index 4d7a54b..249fadc 100644 --- a/save/bitstorage.go +++ b/save/bitstorage.go @@ -26,7 +26,7 @@ type BitStorage struct { // // The "bits" is the number of bits per value, which can be calculated by math/bits.Len() // The "length" is the number of values. -// The "data" is optional for initializing. Panic if data != nil && len(data) != BitStorageSize(bits, length). +// The "data" is optional for initializing. Panic if data != nil && len(data) != calcBitStorageSize(bits, length). func NewBitStorage(bits, length int, data []uint64) (b *BitStorage) { if bits == 0 { return nil @@ -38,7 +38,7 @@ func NewBitStorage(bits, length int, data []uint64) (b *BitStorage) { length: length, valuesPerLong: 64 / bits, } - dataLen := BitStorageSize(bits, length) + dataLen := calcBitStorageSize(bits, length) if data != nil { if len(data) != dataLen { panic(newBitStorageErr{ArrlLen: len(data), WantLen: dataLen}) @@ -50,8 +50,8 @@ func NewBitStorage(bits, length int, data []uint64) (b *BitStorage) { return } -// BitStorageSize calculate how many uint64 is needed for given bits and length. -func BitStorageSize(bits, length int) (size int) { +// calcBitStorageSize calculate how many uint64 is needed for given bits and length. +func calcBitStorageSize(bits, length int) (size int) { if bits == 0 { return 0 } diff --git a/save/palette.go b/save/palette.go index 9930d03..c449549 100644 --- a/save/palette.go +++ b/save/palette.go @@ -11,10 +11,67 @@ type BlockState interface { } type PaletteContainer struct { - maps blockMaps - config func(p *PaletteContainer, bits byte) - palette - BitStorage + bits int + maps IdMaps + config func(maps IdMaps, bits int) palette + palette palette + data *BitStorage +} + +func NewStatesPaletteContainer(maps IdMaps, length int) *PaletteContainer { + return &PaletteContainer{ + bits: 0, + maps: maps, + config: createStatesPalette, + palette: createStatesPalette(maps, 0), + data: NewBitStorage(0, length, nil), + } +} + +func NewBiomesPaletteContainer(maps IdMaps, length int) *PaletteContainer { + return &PaletteContainer{ + bits: 0, + maps: maps, + config: createBiomesPalette, + palette: createBiomesPalette(maps, 0), + data: NewBitStorage(0, length, nil), + } +} + +func (p *PaletteContainer) Get(i int) BlockState { + return p.palette.value(p.data.Get(i)) +} + +func (p *PaletteContainer) Set(i int, v BlockState) { + if vv, ok := p.palette.id(v); ok { + p.data.Set(i, vv) + } else { + // resize + oldLen := p.data.Len() + newPalette := PaletteContainer{ + bits: vv, + maps: p.maps, + config: p.config, + palette: p.config(p.maps, vv), + data: NewBitStorage(vv, oldLen+1, nil), + } + // copy + for i := 0; i < oldLen; i++ { + raw := p.palette.value(i) + if vv, ok := newPalette.palette.id(raw); !ok { + panic("not reachable") + } else { + newPalette.data.Set(i, vv) + } + } + + if vv, ok := newPalette.palette.id(v); !ok { + panic("not reachable") + } else { + newPalette.data.Set(oldLen, vv) + } + *p = newPalette + } } func (p *PaletteContainer) ReadFrom(r io.Reader) (n int64, err error) { @@ -23,7 +80,7 @@ func (p *PaletteContainer) ReadFrom(r io.Reader) (n int64, err error) { if err != nil { return } - p.config(p, byte(bits)) + p.palette = p.config(p.maps, int(bits)) nn, err := p.palette.ReadFrom(r) n += nn @@ -31,7 +88,7 @@ func (p *PaletteContainer) ReadFrom(r io.Reader) (n int64, err error) { return n, err } - nn, err = p.BitStorage.ReadFrom(r) + nn, err = p.data.ReadFrom(r) n += nn if err != nil { return n, err @@ -39,51 +96,46 @@ func (p *PaletteContainer) ReadFrom(r io.Reader) (n int64, err error) { return n, nil } -func createStatesPalette(p *PaletteContainer, bits byte) { +func createStatesPalette(maps IdMaps, bits int) palette { switch bits { case 0: - p.palette = &singleValuePalette{ - onResize: nil, - maps: p.maps, - v: nil, + return &singleValuePalette{ + maps: maps, + v: nil, } case 1, 2, 3, 4: - p.palette = &linearPalette{ - onResize: nil, - maps: p.maps, - bits: 4, + return &linearPalette{ + maps: maps, + bits: 4, } case 5, 6, 7, 8: // TODO: HashMapPalette - p.palette = &linearPalette{ - onResize: nil, - maps: p.maps, - bits: 4, + return &linearPalette{ + maps: maps, + bits: bits, } default: - p.palette = &globalPalette{ - maps: p.maps, + return &globalPalette{ + maps: maps, } } } -func createBiomesPalette(p *PaletteContainer, bits byte) { +func createBiomesPalette(maps IdMaps, bits int) palette { switch bits { case 0: - p.palette = &singleValuePalette{ - onResize: nil, - maps: p.maps, - v: nil, + return &singleValuePalette{ + maps: maps, + v: nil, } case 1, 2, 3: - p.palette = &linearPalette{ - onResize: nil, - maps: p.maps, - bits: 4, + return &linearPalette{ + maps: maps, + bits: bits, } default: - p.palette = &globalPalette{ - maps: p.maps, + return &globalPalette{ + maps: maps, } } } @@ -92,38 +144,37 @@ func (p *PaletteContainer) WriteTo(w io.Writer) (n int64, err error) { return pk.Tuple{ pk.UnsignedByte(p.bits), p.palette, - p.BitStorage, + p.data, }.WriteTo(w) } type palette interface { pk.FieldEncoder pk.FieldDecoder - id(v BlockState) int + id(v BlockState) (int, bool) value(i int) BlockState } -type blockMaps interface { +type IdMaps interface { getID(state BlockState) (id int) getValue(id int) (state BlockState) } type singleValuePalette struct { - onResize func(n int, v BlockState) int - maps blockMaps - v BlockState + maps IdMaps + v BlockState } -func (s *singleValuePalette) id(v BlockState) int { +func (s *singleValuePalette) id(v BlockState) (int, bool) { if s.v == nil { s.v = v - return 0 + return 0, true } if s.v == v { - return 0 + return 0, true } // We have 2 values now. At least 1 bit is required. - return s.onResize(1, v) + return 1, false } func (s *singleValuePalette) value(i int) BlockState { @@ -148,23 +199,22 @@ func (s *singleValuePalette) WriteTo(w io.Writer) (n int64, err error) { } type linearPalette struct { - onResize func(n int, v BlockState) int - maps blockMaps - values []BlockState - bits int + maps IdMaps + values []BlockState + bits int } -func (l *linearPalette) id(v BlockState) int { +func (l *linearPalette) id(v BlockState) (int, bool) { for i, t := range l.values { if t == v { - return i + return i, true } } if cap(l.values)-len(l.values) > 0 { l.values = append(l.values, v) - return len(l.values) - 1 + return len(l.values) - 1, true } - return l.onResize(l.bits+1, v) + return l.bits + 1, false } func (l *linearPalette) value(i int) BlockState { @@ -205,11 +255,11 @@ func (l *linearPalette) WriteTo(w io.Writer) (n int64, err error) { } type globalPalette struct { - maps blockMaps + maps IdMaps } -func (g *globalPalette) id(v BlockState) int { - return g.maps.getID(v) +func (g *globalPalette) id(v BlockState) (int, bool) { + return g.maps.getID(v), true } func (g *globalPalette) value(i int) BlockState { diff --git a/server/dimension.go b/server/dimension.go index c0ff19f..7b9d0eb 100644 --- a/server/dimension.go +++ b/server/dimension.go @@ -6,6 +6,7 @@ import ( pk "github.com/Tnze/go-mc/net/packet" "github.com/Tnze/go-mc/save" "io" + "math/bits" "sync" ) @@ -20,33 +21,74 @@ type DimInfo struct { HashedSeed uint64 } -type SimpleDim struct { - Columns map[struct{ X, Z int }]*struct { - sync.Mutex +type ChunkPos struct{ X, Z int } +type Chunk struct { + sync.Mutex + sections []Section + HeightMaps *save.BitStorage +} + +type Section struct { + blockCount int16 + States *save.PaletteContainer + Biomes *save.PaletteContainer +} + +func (s *Section) WriteTo(w io.Writer) (int64, error) { + return pk.Tuple{ + pk.Short(s.blockCount), + s.States, + s.Biomes, + }.WriteTo(w) +} + +func (s *Section) ReadFrom(r io.Reader) (int64, error) { + return pk.Tuple{ + pk.Short(s.blockCount), + s.States, + s.Biomes, + }.ReadFrom(r) +} + +func EmptyChunk(secs int) *Chunk { + sections := make([]Section, secs) + for i := range sections { + sections[i] = Section{ + blockCount: 0, + States: save.NewStatesPaletteContainer(nil, 16*16*16), + Biomes: save.NewBiomesPaletteContainer(nil, 4*4*4), + } + } + return &Chunk{ + sections: sections, + HeightMaps: save.NewBitStorage(bits.Len(uint(secs)*16), 16*16, nil), } } -type chunkData struct { - HeightMaps save.BitStorage - BlockState save.BitStorage - Biomes save.BitStorage -} - -func (c *chunkData) WriteTo(w io.Writer) (int64, error) { +func (c *Chunk) WriteTo(w io.Writer) (int64, error) { + data, err := c.Data() + if err != nil { + return 0, err + } return pk.Tuple{ // Heightmaps pk.NBT(struct { MotionBlocking []uint64 `nbt:"MOTION_BLOCKING"` }{c.HeightMaps.Raw()}), - pk.ByteArray(c.Data()), // TODO: Chunk Data - pk.VarInt(0), // TODO: Block Entity + pk.ByteArray(data), + pk.VarInt(0), // TODO: Block Entity }.WriteTo(w) } -func (c *chunkData) Data() []byte { +func (c *Chunk) Data() ([]byte, error) { var buff bytes.Buffer - _, _ = pk.Short(0).WriteTo(&buff) - return buff.Bytes() + for _, section := range c.sections { + _, err := section.WriteTo(&buff) + if err != nil { + return nil, err + } + } + return buff.Bytes(), nil } type lightData struct { @@ -76,13 +118,36 @@ func (l *lightData) WriteTo(w io.Writer) (int64, error) { }.WriteTo(w) } +type SimpleDim struct { + numOfSection int + Columns map[ChunkPos]*Chunk +} + +func NewSimpleDim(secs int) *SimpleDim { + return &SimpleDim{ + numOfSection: secs, + Columns: make(map[ChunkPos]*Chunk), + } +} + +func (s *SimpleDim) LoadChunk(pos ChunkPos, c *Chunk) { + s.Columns[pos] = c +} + +func (s *SimpleDim) Info() DimInfo { + return DimInfo{ + Name: "minecraft:overworld", + HashedSeed: 0, + } +} + func (s *SimpleDim) PlayerJoin(p *Player) { for pos, column := range s.Columns { column.Lock() packet := pk.Marshal( packetid.ClientboundLevelChunkWithLight, pk.Int(pos.X), pk.Int(pos.Z), - &chunkData{}, + column, &lightData{ SkyLightMask: make(pk.BitSet, (16*16*16-1)>>6+1), BlockLightMask: make(pk.BitSet, (16*16*16-1)>>6+1), @@ -97,6 +162,18 @@ func (s *SimpleDim) PlayerJoin(p *Player) { return } } + + err := p.WritePacket(Packet757(pk.Marshal( + packetid.ClientboundPlayerPosition, + pk.Double(0), pk.Double(0), pk.Double(0), + pk.Float(0), pk.Float(0), + pk.Byte(0), + pk.VarInt(0), + pk.Boolean(true), + ))) + if err != nil { + return + } } func (s *SimpleDim) PlayerQuit(p *Player) { diff --git a/server/gameplay.go b/server/gameplay.go index 8c4a955..068325d 100644 --- a/server/gameplay.go +++ b/server/gameplay.go @@ -2,6 +2,7 @@ package server import ( _ "embed" + "github.com/Tnze/go-mc/chat" "github.com/Tnze/go-mc/nbt" "sync/atomic" @@ -23,6 +24,7 @@ type GamePlay interface { type Game struct { eid int32 Dim Dimension + *PlayerList } //go:embed DimensionCodec.snbt @@ -32,6 +34,18 @@ var dimensionCodecSNBT string var dimensionSNBT string func (g *Game) AcceptPlayer(name string, id uuid.UUID, protocol int32, conn *net.Conn) { + remove := g.PlayerList.TryInsert(PlayerSample{ + Name: name, + ID: id, + }) + if remove == nil { + _ = conn.WritePacket(pk.Marshal( + packetid.ClientboundDisconnect, + chat.TranslateMsg("multiplayer.disconnect.server_full"), + )) + return + } + defer remove() p := &Player{ Conn: conn, EntityID: g.newEID(), @@ -61,6 +75,21 @@ func (g *Game) AcceptPlayer(name string, id uuid.UUID, protocol int32, conn *net return } g.Dim.PlayerJoin(p) + defer g.Dim.PlayerQuit(p) + + var packet pk.Packet + for { + err := p.ReadPacket(&packet) + if err != nil { + return + } + for _, ph := range p.handlers[packet.ID] { + err = ph(p, Packet757(packet)) + } + if err != nil { + return + } + } } func (g *Game) newEID() int32 { diff --git a/server/player.go b/server/player.go index 565eeb8..3d1ac5c 100644 --- a/server/player.go +++ b/server/player.go @@ -9,6 +9,7 @@ type Player struct { *net.Conn EntityID int32 Gamemode byte + handlers map[int32][]packetHandlerFunc } // Packet757 is a packet in protocol 757. @@ -19,3 +20,17 @@ type Packet757 pk.Packet func (p *Player) WritePacket(packet Packet757) error { return p.Conn.WritePacket(pk.Packet(packet)) } + +type PacketHandler struct { + ID int32 + F packetHandlerFunc +} + +type packetHandlerFunc func(player *Player, packet Packet757) error + +func (p *Player) Add(ph PacketHandler) { + if p.handlers == nil { + p.handlers = make(map[int32][]packetHandlerFunc) + } + p.handlers[ph.ID] = append(p.handlers[ph.ID], ph.F) +}