Adjust blockentities.go.tmpl

This commit is contained in:
Tnze
2022-12-19 00:57:50 +08:00
parent c1a6528a05
commit ebba0a6a63
3 changed files with 7 additions and 12 deletions

View File

@ -19,7 +19,8 @@ func ({{.Name | ToGoTypeName}}Entity) ID() string { return {{.Name | printf "%q"
{{- end}}
{{range .}}
func ({{.Name | ToFuncReceiverName}} {{.Name | ToGoTypeName}}Entity) IsValidBlock(block Block) bool {
{{- $v := slice (.Name | ToLower) 0 1 }}
func ({{$v}} {{.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}}: