Add BlockEntity support

This commit is contained in:
Tnze
2022-12-18 18:28:08 +08:00
parent 27b1347e74
commit c1a6528a05
10 changed files with 712 additions and 153 deletions

View File

@ -0,0 +1,31 @@
// Code generated by {{Generator}}; DO NOT EDIT.
package block
{{/* type (
{{- range .}}
{{.Name | ToGoTypeName}}Entity struct {}
{{- end}}
) */}}
var EntityList = [...]Entity{
{{- range .}}
{{.Name | ToGoTypeName}}Entity{},
{{- end}}
}
{{- range .}}
func ({{.Name | ToGoTypeName}}Entity) ID() string { return {{.Name | printf "%q"}} }
{{- end}}
{{range .}}
func ({{.Name | ToFuncReceiverName}} {{.Name | ToGoTypeName}}Entity) IsValidBlock(block Block) bool {
{{if eq 1 (len .ValidBlocks)}}return block.ID() == {{index .ValidBlocks 0 | printf "%q"}}{{else}}switch block.ID() {
case {{index .ValidBlocks 0 | printf "%q"}}{{range slice .ValidBlocks 1}},
{{. | printf "%q"}}{{end}}:
return true
default:
return false
}{{end}}
}
{{end}}