Update level structure to 1.19.2

This commit is contained in:
maxsupermanhd
2022-11-02 16:41:06 +03:00
parent 5a1fcfb0cf
commit 9559d68c9d
2 changed files with 152 additions and 55 deletions

81
save/dimension.go Normal file
View File

@ -0,0 +1,81 @@
package save
// https://minecraft.fandom.com/wiki/Custom_dimension
type DimensionType struct {
BonusChest bool `nbt:"bonus_chest"`
// When false, compasses spin randomly, and using a bed to set the respawn point or sleep, is disabled. When true, nether portals can spawn zombified piglins.
Natural bool `nbt:"natural"`
// The multiplier applied to coordinates when leaving the dimension. Value between 0.00001 and 30000000.0 (both inclusive)
CoordinatesScale float64 `nbt:"coordinate_scale"`
HasSkylight bool `nbt:"has_skylight"`
HasCeiling bool `nbt:"has_ceiling"`
AmbientLight float32 `nbt:"ambient_light"`
FixedTime int64 `nbt:"fixed_time,omitempty"`
// idk what this really is, looks like an integer
MonsterSpawnLightLevel int32 `nbt:"monster_spawn_light_level"`
MonsterSpawnBlockLightLimit int32 `nbt:"monster_spawn_block_light_limit"`
PiglinSafe bool `nbt:"piglin_safe"`
BedWorks bool `nbt:"bed_works"`
RespawnAnchorWorks bool `nbt:"respawn_anchor_works"`
HasRaids bool `nbt:"has_raids"`
LogicalHeight int32 `nbt:"logical_height"`
MinY int32 `nbt:"min_y"`
Height int32 `nbt:"height"`
Infiniburn string `nbt:"infiniburn"`
Effects string `nbt:"effects"`
}
type WorldGenSettings struct {
BonusChest bool `nbt:"bonus_chest"`
GenerateFeatures bool `nbt:"generate_features"`
Seed int64 `nbt:"seed"`
Dimensions map[string]DimensionGenerator `nbt:"dimensions"`
}
type DimensionGenerator struct {
Type string `nbt:"type"`
Generator map[string]interface{} `nbt:"generator"`
}
var (
// as of 1.19.2
DefaultDimensions = map[string]DimensionGenerator{
"minecraft:overworld": {
Type: "minecraft:overworld",
Generator: map[string]interface{}{
"type": "minecraft:noise",
"settings": "minecraft:overworld",
"biome_source": map[string]string{
"preset": "minecraft:overworld",
"type": "minecraft:multi_noise",
},
},
},
"minecraft:the_end": {
Type: "minecraft:the_end",
Generator: map[string]interface{}{
"type": "minecraft:noise",
"settings": "minecraft:end",
"biome_source": map[string]string{
"type": "minecraft:the_end",
},
},
},
"minecraft:the_nether": {
Type: "minecraft:the_nether",
Generator: map[string]interface{}{
"type": "minecraft:noise",
"settings": "minecraft:nether",
"biome_source": map[string]string{
"preset": "minecraft:nether",
"type": "minecraft:multi_noise",
},
},
},
}
)

View File

@ -1,34 +1,17 @@
package save package save
import ( import (
"github.com/Tnze/go-mc/nbt"
"io" "io"
"github.com/Tnze/go-mc/nbt"
) )
type Level struct { type Level struct {
Data struct { Data LevelData
DataVersion int32
NBTVersion int32 `nbt:"version"`
Version struct {
ID int32 `nbt:"Id"`
Name string
Snapshot byte
} }
GameType int32
Difficulty byte type LevelData struct {
DifficultyLocked byte
HardCore byte `nbt:"hardcore"`
Initialized byte `nbt:"initialized"`
AllowCommands byte `nbt:"allowCommands"` AllowCommands byte `nbt:"allowCommands"`
MapFeatures byte
LevelName string
GeneratorName string `nbt:"generatorName"`
GeneratorVersion int32 `nbt:"generatorVersion"`
RandomSeed int64
SpawnX, SpawnY, SpawnZ int32
BorderCenterX, BorderCenterZ float64 BorderCenterX, BorderCenterZ float64
BorderDamagePerBlock float64 BorderDamagePerBlock float64
BorderSafeZone float64 BorderSafeZone float64
@ -37,11 +20,15 @@ type Level struct {
BorderSizeLerpTime int64 BorderSizeLerpTime int64
BorderWarningBlocks float64 BorderWarningBlocks float64
BorderWarningTime float64 BorderWarningTime float64
ClearWeatherTime int32 `nbt:"clearWeatherTime"`
GameRules map[string]string CustomBossEvents map[string]CustomBossEvent
DataPacks struct { DataPacks struct {
Enabled, Disabled []string Enabled, Disabled []string
} }
DataVersion int32
DayTime int64
Difficulty byte
DifficultyLocked bool
DimensionData struct { DimensionData struct {
TheEnd struct { TheEnd struct {
DragonFight struct { DragonFight struct {
@ -51,17 +38,46 @@ type Level struct {
} }
} `nbt:"1"` } `nbt:"1"`
} }
GameRules map[string]string
Raining byte `nbt:"raining"` WorldGenSettings WorldGenSettings
Thundering byte `nbt:"thundering"` GameType int32
RainTime int32 `nbt:"rainTime"` HardCore bool `nbt:"hardcore"`
ThunderTime int32 `nbt:"thunderTime"` Initialized bool `nbt:"initialized"`
ClearWeatherTime int32 `nbt:"clearWeatherTime"`
Time int64
DayTime int64
LastPlayed int64 LastPlayed int64
LevelName string
MapFeatures bool
Player map[string]interface{}
Raining bool `nbt:"raining"`
RainTime int32 `nbt:"rainTime"`
RandomSeed int64
SizeOnDisk int64
SpawnX, SpawnY, SpawnZ int32
Thundering bool `nbt:"thundering"`
ThunderTime int32 `nbt:"thunderTime"`
Time int64
Version struct {
ID int32 `nbt:"Id"`
Name string
Series string
Snapshot byte
} }
WanderingTraderId []int32
WanderingTraderSpawnChance int32
WanderingTraderSpawnDelay int32
WasModded bool
}
type CustomBossEvent struct {
Players [][]int32
Color string
CreateWorldFog bool
DarkenScreen bool
Max int32
Value int32
Name string
Overlay string
PlayBossMusic bool
Visible bool
} }
func ReadLevel(r io.Reader) (data Level, err error) { func ReadLevel(r io.Reader) (data Level, err error) {