This commit is contained in:
adman
2025-12-15 22:07:37 +01:00
parent 01bf2a575c
commit 6108534a12
1118 changed files with 13788358 additions and 331 deletions
+68
View File
@@ -0,0 +1,68 @@
package data
// {
// "id": 0,
// "name": "air",
// "displayName": "Air",
// "hardness": 0.0,
// "resistance": 0.0,
// "stackSize": 64,
// "diggable": false,
// "material": "default",
// "transparent": true,
// "emitLight": 0,
// "filterLight": 0,
// "defaultState": 0,
// "minStateId": 0,
// "maxStateId": 0,
// "states": [],
// "drops": [],
// "boundingBox": "empty"
// },
type Block struct {
Id int
Name string
DisplayName string
Hardness float64
Resistance float64
StackSize int
Diggable bool
Material string
Transparent bool
EmitLight int
FilterLight int
DefaultState int32
MinStateId int32
MaxStateId int32
States []struct {
Name string
Type string
NumValues int
}
Drops []int
BoundingBox string
}
var BlocksCache = make(map[string][]Block)
func BlocksForVersion(v string) (ret []Block) {
var ok bool
if ret, ok = BlocksCache[v]; ok {
return
}
var b []Block
must(LoadVersionedJson(v, "blocks", &b))
BlocksCache[v] = b
return b
}
func LookupBlockByStateId(version string, stateId int32) (block Block, ok bool) {
for _, b := range BlocksForVersion(version) {
if b.MinStateId <= stateId && stateId <= b.MaxStateId {
block = b
ok = true
}
}
return
}