1.19.2 chat support
This commit is contained in:
8
registry/chattype.go
Normal file
8
registry/chattype.go
Normal file
@ -0,0 +1,8 @@
|
||||
package registry
|
||||
|
||||
import "github.com/Tnze/go-mc/chat"
|
||||
|
||||
type ChatType struct {
|
||||
Chat chat.Decoration `nbt:"chat"`
|
||||
Narration chat.Decoration `nbt:"narration"`
|
||||
}
|
9
registry/codec.go
Normal file
9
registry/codec.go
Normal file
@ -0,0 +1,9 @@
|
||||
package registry
|
||||
|
||||
import "github.com/Tnze/go-mc/nbt"
|
||||
|
||||
type NetworkCodec struct {
|
||||
ChatType Registry[ChatType] `nbt:"minecraft:chat_type"`
|
||||
DimensionType Registry[Dimension] `nbt:"minecraft:dimension_type"`
|
||||
WorldGenBiome Registry[nbt.RawMessage] `nbt:"minecraft:worldgen/biome"`
|
||||
}
|
25
registry/dimension.go
Normal file
25
registry/dimension.go
Normal file
@ -0,0 +1,25 @@
|
||||
package registry
|
||||
|
||||
import "github.com/Tnze/go-mc/nbt"
|
||||
|
||||
type Dimension struct {
|
||||
FixedTime int64 `nbt:"fixed_time,omitempty"`
|
||||
HasSkylight bool `nbt:"has_skylight"`
|
||||
HasCeiling bool `nbt:"has_ceiling"`
|
||||
Ultrawarm bool `nbt:"ultrawarm"`
|
||||
Natural bool `nbt:"natural"`
|
||||
CoordinateScale float64 `nbt:"coordinate_scale"`
|
||||
BedWorks bool `nbt:"bed_works"`
|
||||
RespawnAnchorWorks byte `nbt:"respawn_anchor_works"`
|
||||
MinY int32 `nbt:"min_y"`
|
||||
Height int32 `nbt:"height"`
|
||||
LogicalHeight int32 `nbt:"logical_height"`
|
||||
InfiniteBurn string `nbt:"infiniburn"`
|
||||
Effects string `nbt:"effects"`
|
||||
AmbientLight float64 `nbt:"ambient_light"`
|
||||
|
||||
PiglinSafe byte `nbt:"piglin_safe"`
|
||||
HasRaids byte `nbt:"has_raids"`
|
||||
MonsterSpawnLightLevel nbt.RawMessage `nbt:"monster_spawn_light_level"` // Tag_Int or {type:"minecraft:uniform", value:{min_inclusive: Tag_Int, max_inclusive: Tag_Int}}
|
||||
MonsterSpawnBlockLightLimit int32 `nbt:"monster_spawn_block_light_limit"`
|
||||
}
|
31
registry/registry.go
Normal file
31
registry/registry.go
Normal file
@ -0,0 +1,31 @@
|
||||
package registry
|
||||
|
||||
type Registry[E any] struct {
|
||||
Type string `nbt:"type"`
|
||||
Value []struct {
|
||||
Name string `nbt:"name"`
|
||||
ID int32 `nbt:"id"`
|
||||
Element E `nbt:"element"`
|
||||
} `nbt:"value"`
|
||||
}
|
||||
|
||||
func (r *Registry[E]) Find(name string) (int32, *E) {
|
||||
for i := range r.Value {
|
||||
if r.Value[i].Name == name {
|
||||
return int32(i), &r.Value[i].Element
|
||||
}
|
||||
}
|
||||
return -1, nil
|
||||
}
|
||||
|
||||
func (r *Registry[E]) FindByID(id int32) *E {
|
||||
if id >= 0 && id < int32(len(r.Value)) && r.Value[id].ID == id {
|
||||
return &r.Value[id].Element
|
||||
}
|
||||
for i := range r.Value {
|
||||
if r.Value[i].ID == id {
|
||||
return &r.Value[i].Element
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user