leveldat

package
v1.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CurrentProtocol is the current protocol version for the version below.
	CurrentProtocol = 686
	// CurrentVersion is the current version of NetEase Minecraft Bedrock.
	CurrentVersion = "1.21.1"
)
View Source
const Version = 10

Version is the current version stored in level.dat files.

Variables

This section is empty.

Functions

func LowerMapKeyName

func LowerMapKeyName(src map[string]any) (dst map[string]any)

LowerMapKeyName make all the key in src to its lower represents. Of course, this changes will also made on all the sub-maps of src.

Types

type Data

type Data struct {
	BaseGameVersion                string  `nbt:"baseGameVersion"`
	BiomeOverride                  string  `nbt:"BiomeOverride"`
	ConfirmedPlatformLockedContent bool    `nbt:"ConfirmedPlatformLockedContent"`
	CenterMapsToOrigin             bool    `nbt:"CenterMapsToOrigin"`
	CheatsEnabled                  bool    `nbt:"cheatsEnabled"`
	DaylightCycle                  int32   `nbt:"daylightCycle"`
	Difficulty                     int32   `nbt:"Difficulty"`
	EduOffer                       int32   `nbt:"eduOffer"`
	FlatWorldLayers                string  `nbt:"FlatWorldLayers"`
	ForceGameType                  bool    `nbt:"ForceGameType"`
	GameType                       int32   `nbt:"GameType"`
	Generator                      int32   `nbt:"Generator"`
	InventoryVersion               string  `nbt:"InventoryVersion"`
	LANBroadcast                   bool    `nbt:"LANBroadcast"`
	LANBroadcastIntent             bool    `nbt:"LANBroadcastIntent"`
	LastPlayed                     int64   `nbt:"LastPlayed"`
	LevelName                      string  `nbt:"LevelName"`
	LimitedWorldOriginX            int32   `nbt:"LimitedWorldOriginX"`
	LimitedWorldOriginY            int32   `nbt:"LimitedWorldOriginY"`
	LimitedWorldOriginZ            int32   `nbt:"LimitedWorldOriginZ"`
	LimitedWorldDepth              int32   `nbt:"limitedWorldDepth"`
	LimitedWorldWidth              int32   `nbt:"limitedWorldWidth"`
	MinimumCompatibleClientVersion []int32 `nbt:"MinimumCompatibleClientVersion"`
	MultiPlayerGame                bool    `nbt:"MultiplayerGame"`
	MultiPlayerGameIntent          bool    `nbt:"MultiplayerGameIntent"`
	NetherScale                    int32   `nbt:"NetherScale"`
	NetworkVersion                 int32   `nbt:"NetworkVersion"`
	Platform                       int32   `nbt:"Platform"`
	PlatformBroadcastIntent        int32   `nbt:"PlatformBroadcastIntent"`
	RandomSeed                     int64   `nbt:"RandomSeed"`
	ShowTags                       bool    `nbt:"showtags"`
	SingleUseWorld                 bool    `nbt:"isSingleUseWorld"`
	SpawnX                         int32   `nbt:"SpawnX"`
	SpawnY                         int32   `nbt:"SpawnY"`
	SpawnZ                         int32   `nbt:"SpawnZ"`
	SpawnV1Villagers               bool    `nbt:"SpawnV1Villagers"`
	StorageVersion                 int32   `nbt:"StorageVersion"`
	Time                           int64   `nbt:"Time"`
	XBLBroadcast                   bool    `nbt:"XBLBroadcast"`
	XBLBroadcastIntent             int32   `nbt:"XBLBroadcastIntent"`
	XBLBroadcastMode               int32   `nbt:"XBLBroadcastMode"`
	Abilities                      struct {
		AttackMobs             bool    `nbt:"attackmobs"`
		AttackPlayers          bool    `nbt:"attackplayers"`
		Build                  bool    `nbt:"build"`
		Mine                   bool    `nbt:"mine"`
		DoorsAndSwitches       bool    `nbt:"doorsandswitches"`
		FlySpeed               float32 `nbt:"flySpeed"`
		Flying                 bool    `nbt:"flying"`
		InstantBuild           bool    `nbt:"instabuild"`
		Invulnerable           bool    `nbt:"invulnerable"`
		Lightning              bool    `nbt:"lightning"`
		MayFly                 bool    `nbt:"mayfly"`
		OP                     bool    `nbt:"op"`
		OpenContainers         bool    `nbt:"opencontainers"`
		PermissionsLevel       int32   `nbt:"permissionsLevel"`
		PlayerPermissionsLevel int32   `nbt:"playerPermissionsLevel"`
		Teleport               bool    `nbt:"teleport"`
		WalkSpeed              float32 `nbt:"walkSpeed"`
		VerticalFlySpeed       float32 `nbt:"verticalFlySpeed"`
	} `nbt:"abilities"`
	BonusChestEnabled               bool           `nbt:"bonusChestEnabled"`
	BonusChestSpawned               bool           `nbt:"bonusChestSpawned"`
	CommandBlockOutput              bool           `nbt:"commandblockoutput"`
	CommandBlocksEnabled            bool           `nbt:"commandblocksenabled"`
	CommandsEnabled                 bool           `nbt:"commandsEnabled"`
	CurrentTick                     int64          `nbt:"currentTick"`
	DoDayLightCycle                 bool           `nbt:"dodaylightcycle"`
	DoEntityDrops                   bool           `nbt:"doentitydrops"`
	DoFireTick                      bool           `nbt:"dofiretick"`
	DoImmediateRespawn              bool           `nbt:"doimmediaterespawn"`
	DoInsomnia                      bool           `nbt:"doinsomnia"`
	DoMobLoot                       bool           `nbt:"domobloot"`
	DoMobSpawning                   bool           `nbt:"domobspawning"`
	DoTileDrops                     bool           `nbt:"dotiledrops"`
	DoWeatherCycle                  bool           `nbt:"doweathercycle"`
	DrowningDamage                  bool           `nbt:"drowningdamage"`
	EduLevel                        bool           `nbt:"eduLevel"`
	EducationFeaturesEnabled        bool           `nbt:"educationFeaturesEnabled"`
	ExperimentalGamePlay            bool           `nbt:"experimentalgameplay"`
	FallDamage                      bool           `nbt:"falldamage"`
	FireDamage                      bool           `nbt:"firedamage"`
	FunctionCommandLimit            int32          `nbt:"functioncommandlimit"`
	HasBeenLoadedInCreative         bool           `nbt:"hasBeenLoadedInCreative"`
	HasLockedBehaviourPack          bool           `nbt:"hasLockedBehaviorPack"`
	HasLockedResourcePack           bool           `nbt:"hasLockedResourcePack"`
	ImmutableWorld                  bool           `nbt:"immutableWorld"`
	IsCreatedInEditor               bool           `nbt:"isCreatedInEditor"`
	IsExportedFromEditor            bool           `nbt:"isExportedFromEditor"`
	IsFromLockedTemplate            bool           `nbt:"isFromLockedTemplate"`
	IsFromWorldTemplate             bool           `nbt:"isFromWorldTemplate"`
	IsWorldTemplateOptionLocked     bool           `nbt:"isWorldTemplateOptionLocked"`
	KeepInventory                   bool           `nbt:"keepinventory"`
	LastOpenedWithVersion           []int32        `nbt:"lastOpenedWithVersion"`
	LightningLevel                  float32        `nbt:"lightningLevel"`
	LightningTime                   int32          `nbt:"lightningTime"`
	MaxCommandChainLength           int32          `nbt:"maxcommandchainlength"`
	MobGriefing                     bool           `nbt:"mobgriefing"`
	NaturalRegeneration             bool           `nbt:"naturalregeneration"`
	PRID                            string         `nbt:"prid"`
	PVP                             bool           `nbt:"pvp"`
	RainLevel                       float32        `nbt:"rainLevel"`
	RainTime                        int32          `nbt:"rainTime"`
	RandomTickSpeed                 int32          `nbt:"randomtickspeed"`
	RequiresCopiedPackRemovalCheck  bool           `nbt:"requiresCopiedPackRemovalCheck"`
	SendCommandFeedback             bool           `nbt:"sendcommandfeedback"`
	ServerChunkTickRange            int32          `nbt:"serverChunkTickRange"`
	ShowCoordinates                 bool           `nbt:"showcoordinates"`
	ShowDeathMessages               bool           `nbt:"showdeathmessages"`
	SpawnMobs                       bool           `nbt:"spawnMobs"`
	SpawnRadius                     int32          `nbt:"spawnradius"`
	StartWithMapEnabled             bool           `nbt:"startWithMapEnabled"`
	TexturePacksRequired            bool           `nbt:"texturePacksRequired"`
	TNTExplodes                     bool           `nbt:"tntexplodes"`
	UseMSAGamerTagsOnly             bool           `nbt:"useMsaGamertagsOnly"`
	WorldStartCount                 int64          `nbt:"worldStartCount"`
	Experiments                     map[string]any `nbt:"experiments"`
	FreezeDamage                    bool           `nbt:"freezedamage"`
	WorldPolicies                   map[string]any `nbt:"world_policies"`
	WorldVersion                    int32          `nbt:"WorldVersion"`
	RespawnBlocksExplode            bool           `nbt:"respawnblocksexplode"`
	ShowBorderEffect                bool           `nbt:"showbordereffect"`
	PermissionsLevel                int32          `nbt:"permissionsLevel"`
	PlayerPermissionsLevel          int32          `nbt:"playerPermissionsLevel"`
	IsRandomSeedAllowed             bool           `nbt:"isRandomSeedAllowed"`
	DoLimitedCrafting               bool           `nbt:"dolimitedcrafting"`
	EditorWorldType                 int32          `nbt:"editorWorldType"`
	PlayersSleepingPercentage       int32          `nbt:"playerssleepingpercentage"`
	RecipesUnlock                   bool           `nbt:"recipesunlock"`
	NaturalGeneration               bool           `nbt:"naturalgeneration"`
	ProjectilesCanBreakBlocks       bool           `nbt:"projectilescanbreakblocks"`
	ShowRecipeMessages              bool           `nbt:"showrecipemessages"`
	IsHardcore                      bool           `nbt:"IsHardcore"`
	ShowDaysPlayed                  bool           `nbt:"showdaysplayed"`
	TNTExplosionDropDecay           bool           `nbt:"tntexplosiondropdecay"`
	HasUncompleteWorldFileOnDisk    bool           `nbt:"HasUncompleteWorldFileOnDisk"`
	PlayerHasDied                   bool           `nbt:"PlayerHasDied"`
	NeteaseEncryptFlag              bool           `nbt:"neteaseEncryptFlag"`              // Netease
	NeteaseStrongholdSelectedChunks [][]int64      `nbt:"neteaseStrongholdSelectedChunks"` // Netease
}

Data holds a collection of data that specify a range of Settings of the world. These Settings usually alter the way that players interact with the world. The data held here is usually saved in a level.dat file of the world. Data may be used in LevelDat.Unmarshal to collect the data of the level.dat.

func (*Data) FillDefault

func (d *Data) FillDefault()

FillDefault fills out d with all the default level.dat values.

type LevelDat

type LevelDat struct {
	// contains filtered or unexported fields
}

LevelDat implements the encoding and decoding of level.dat files. An empty LevelDat is a valid value and may be used to Marshal and Write to a writer or file afterward.

func Read

func Read(r io.Reader) (*LevelDat, error)

Read reads a level.dat from r and returns it.

func ReadFile

func ReadFile(name string) (*LevelDat, error)

ReadFile reads a level.dat at a path and returns it.

func (*LevelDat) Marshal

func (ld *LevelDat) Marshal(src any) error

Marshal encodes src and stores it in the level.dat. src should be either a struct or a map of fields. Marshal updates the storage version to the latest.

func (*LevelDat) Unmarshal

func (ld *LevelDat) Unmarshal(dst any) error

Unmarshal decodes the level.dat properties from ld into dst. Unmarshal returns an error if dst was unable to store all properties found in the level.dat.

func (*LevelDat) Ver

func (ld *LevelDat) Ver() int

Ver returns the version of the level.dat decoded, or 0 if ld is the empty value.

func (*LevelDat) Write

func (ld *LevelDat) Write(w io.Writer) error

Write writes ld to w.

func (*LevelDat) WriteFile

func (ld *LevelDat) WriteFile(name string) error

WriteFile writes ld to a file at name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址