format repo with "gofumpt" tool
This commit is contained in:
@ -8,8 +8,10 @@ import (
|
||||
pk "github.com/Tnze/go-mc/net/packet"
|
||||
)
|
||||
|
||||
const indexOutOfBounds = "index out of bounds"
|
||||
const valueOutOfBounds = "value out of bounds"
|
||||
const (
|
||||
indexOutOfBounds = "index out of bounds"
|
||||
valueOutOfBounds = "value out of bounds"
|
||||
)
|
||||
|
||||
// BitStorage implement the compacted data array used in chunk storage and heightmaps.
|
||||
// You can think of this as a []intN whose N is called "bits" in NewBitStorage.
|
||||
|
@ -1,14 +1,17 @@
|
||||
package level
|
||||
|
||||
import (
|
||||
pk "github.com/Tnze/go-mc/net/packet"
|
||||
"math/bits"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
pk "github.com/Tnze/go-mc/net/packet"
|
||||
)
|
||||
|
||||
var data = []uint64{0x0020863148418841, 0x01018A7260F68C87}
|
||||
var want = []int{1, 2, 2, 3, 4, 4, 5, 6, 6, 4, 8, 0, 7, 4, 3, 13, 15, 16, 9, 14, 10, 12, 0, 2}
|
||||
var (
|
||||
data = []uint64{0x0020863148418841, 0x01018A7260F68C87}
|
||||
want = []int{1, 2, 2, 3, 4, 4, 5, 6, 6, 4, 8, 0, 7, 4, 3, 13, 15, 16, 9, 14, 10, 12, 0, 2}
|
||||
)
|
||||
|
||||
func TestBitStorage_Get(t *testing.T) {
|
||||
bs := NewBitStorage(5, 24, data)
|
||||
|
@ -20,18 +20,22 @@ type Block interface {
|
||||
//go:embed block_states.nbt
|
||||
var blockStates []byte
|
||||
|
||||
var ToStateID map[Block]StateID
|
||||
var StateList []Block
|
||||
var (
|
||||
ToStateID map[Block]StateID
|
||||
StateList []Block
|
||||
)
|
||||
|
||||
// BitsPerBlock indicates how many bits are needed to represent all possible
|
||||
// block states. This value is used to determine the size of the global palette.
|
||||
var BitsPerBlock int
|
||||
|
||||
type StateID int
|
||||
type State struct {
|
||||
Name string
|
||||
Properties nbt.RawMessage
|
||||
}
|
||||
type (
|
||||
StateID int
|
||||
State struct {
|
||||
Name string
|
||||
Properties nbt.RawMessage
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
var states []State
|
||||
|
@ -70,7 +70,7 @@ func genSourceFile(states []State) {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = os.WriteFile("blocks.go", formattedSource, 0666)
|
||||
err = os.WriteFile("blocks.go", formattedSource, 0o666)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
err = os.WriteFile("properties_enum.go", formattedSource, 0666)
|
||||
err = os.WriteFile("properties_enum.go", formattedSource, 0o666)
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
|
@ -406,6 +406,7 @@ type Section struct {
|
||||
func (s *Section) GetBlock(i int) BlocksState {
|
||||
return s.States.Get(i)
|
||||
}
|
||||
|
||||
func (s *Section) SetBlock(i int, v BlocksState) {
|
||||
if block.IsAir(s.States.Get(i)) {
|
||||
s.BlockCount--
|
||||
|
@ -13,8 +13,10 @@ import (
|
||||
type State interface {
|
||||
~int
|
||||
}
|
||||
type BlocksState = block.StateID
|
||||
type BiomesState int
|
||||
type (
|
||||
BlocksState = block.StateID
|
||||
BiomesState int
|
||||
)
|
||||
|
||||
type PaletteContainer[T State] struct {
|
||||
bits int
|
||||
@ -206,6 +208,7 @@ func (b biomesCfg) bits(bits int) int {
|
||||
return biome.BitsPerBiome
|
||||
}
|
||||
}
|
||||
|
||||
func (b biomesCfg) create(bits int) palette[BiomesState] {
|
||||
switch bits {
|
||||
case 0:
|
||||
|
Reference in New Issue
Block a user