Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for custom blocks #512

Merged
merged 88 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
2fa6415
Start of custom blocks.. yeah
TwistedAsylumMC Apr 3, 2022
a0466b6
Merge branch 'master' into feature/custom-blocks
TwistedAsylumMC May 15, 2022
dfeca65
packbuilder/blocks.go: Fix package name
TwistedAsylumMC May 15, 2022
b0b0a4a
world/block_state.go: horrible horrible horrible sorting code.
JustTalDevelops May 21, 2022
fca2e6a
world/block_state.go: woops
JustTalDevelops May 21, 2022
a01a1ba
world/block_state.go: Properly register existing states.
JustTalDevelops May 21, 2022
4e8a57d
world/block_state.go: Possibly simplify code.
JustTalDevelops May 21, 2022
8a06a04
world/block_state.go: Don't sort unnecessarily.
JustTalDevelops May 21, 2022
8b7e40f
world/block_state.go: Various fixes.
JustTalDevelops May 21, 2022
8c74e52
block: Added a PHP custom block for testing.
JustTalDevelops May 21, 2022
5222de9
world/block_state.go: Update hashes.
JustTalDevelops May 21, 2022
051c5bb
block/hash.go: Added a NextHash function.
JustTalDevelops May 22, 2022
d90fb7e
customblock: Various material target changes.
JustTalDevelops May 22, 2022
2ee89b3
world/block.go: Improve doc.
JustTalDevelops May 22, 2022
2a4c4b6
customblock/server.go: Properly handle no geometry.
JustTalDevelops May 22, 2022
ca04af0
customblock/material_target.go: Added a Name function.
JustTalDevelops May 22, 2022
c4ea4be
Merge branch 'master' into feature/custom-blocks
JustTalDevelops May 22, 2022
4ea1ef8
block/hash.go: Various fixes.
JustTalDevelops May 22, 2022
5f82b33
server/server.go: Added some basic components. (WIP)
JustTalDevelops May 22, 2022
0dc36c5
customblock/render_method.go: Simplify AmbientOcclusion.
JustTalDevelops May 22, 2022
7d44493
customblock/render_method.go: Fix doc.
JustTalDevelops May 22, 2022
fed0155
customblock/model.go: Use MaterialTarget.
JustTalDevelops May 22, 2022
58d8b64
Merge remote-tracking branch 'origin/feature/custom-blocks' into feat…
JustTalDevelops May 22, 2022
7027e3f
customblock/render_method.go: consistency!!11
JustTalDevelops May 22, 2022
ed227b4
customblock/model.go: woops.
JustTalDevelops May 22, 2022
94f0edf
server/server.go: consistency v2
JustTalDevelops May 22, 2022
19f2562
world/block_state.go: Various improvements.
JustTalDevelops May 22, 2022
c541855
world/block_state.go: Remove debug.
JustTalDevelops May 22, 2022
9e82cab
world/block_state.go: Woops.
JustTalDevelops May 22, 2022
d2f9ebd
world/block_state.go: Update airRID.
JustTalDevelops May 22, 2022
7419a89
server/server.go: Actually use components.
JustTalDevelops May 22, 2022
502fac7
server/server.go: Component fixes.
JustTalDevelops May 22, 2022
cd61a67
world/block_state.go: Cleaned up a ton of code.
JustTalDevelops May 22, 2022
f158efe
block/php.go: Removed changes.
JustTalDevelops May 22, 2022
52ccfa5
main.go: Fix creative item count.
JustTalDevelops May 22, 2022
0cd2b2e
world/block_state.go: Various changes.
JustTalDevelops May 23, 2022
6847587
server/server.go: Fix the LightEmitter component.
JustTalDevelops May 23, 2022
fb56c62
server/server.go: Fix creative items not properly functioning + light…
JustTalDevelops May 23, 2022
9c2bc3f
server/server.go: Support properties for custom blocks.
JustTalDevelops May 23, 2022
f997312
world/block.go: Fixesss
JustTalDevelops May 23, 2022
5341d42
packbuilder/blocks.go: Use Sprintf for consistency.
JustTalDevelops May 23, 2022
14e2f57
blockinternal: Moved component building.
JustTalDevelops May 24, 2022
4fc2be4
fixed client crashes caused by empty block entry
DaPigGuy May 24, 2022
3436f2e
server/server.go: Made an itemComponentEntries function for consistency.
JustTalDevelops May 24, 2022
6452534
blockinternal/blocks.go: Permutations?
JustTalDevelops May 24, 2022
ed0d697
block/php.go: woops.
JustTalDevelops May 24, 2022
9025740
blockinternal/builder.go: Set Molang version.
JustTalDevelops May 24, 2022
b5f3994
blockinternal/builder.go: Update Empty check.
JustTalDevelops May 24, 2022
b71c60b
blockinternal/builder.go: Remove useless Empty.
JustTalDevelops May 24, 2022
c02ffe9
blockinternal/builder.go: Remove useless Values.
JustTalDevelops May 24, 2022
d0c2f68
world/block.go: Allow custom blocks to opt into custom geometry.
JustTalDevelops May 24, 2022
10efae1
blockinternal/components.go: More of permutations.
JustTalDevelops May 25, 2022
40a61a7
blockinternal/components.go: Docs.
JustTalDevelops May 25, 2022
77dad5f
block/pig.go: Changes.
JustTalDevelops May 25, 2022
7954a8a
block/pig.go: Made Pig flammable.
JustTalDevelops May 25, 2022
ae0f82d
block/pig.go: Changes to permutation API.
JustTalDevelops May 26, 2022
43b4f50
block/block.go: Removed Placeable.
JustTalDevelops May 26, 2022
bfef090
block/material_target.go: Added missing material targets.
JustTalDevelops May 26, 2022
fa457da
block/pig.go: Start implementing new permutation system.
JustTalDevelops May 26, 2022
5de1093
blockinternal/components.go: More changes.
JustTalDevelops May 26, 2022
4ceb8c4
blockinternal/components.go: Support for other permutable components.
JustTalDevelops May 27, 2022
5ef03d6
block/pig.go: Various changes.
JustTalDevelops May 27, 2022
11e9225
blockinternal/builder.go: Set aim and block collision boxes.
JustTalDevelops May 27, 2022
7e5eb82
blockinternal/builder.go: Various changes.
JustTalDevelops May 27, 2022
1c29cdc
Merge branch 'master' into feature/custom-blocks
JustTalDevelops Jul 22, 2022
112cf1c
dragonfly: Various fixes to custom blocks.
JustTalDevelops Jul 22, 2022
195a269
world/block_state.go: Use fast hash.
JustTalDevelops Jul 22, 2022
ba461ea
customblock: Some work on permutation specific textures + cleanup.
JustTalDevelops Jul 22, 2022
ceed0c5
customblock: Permutation-specific geometry.
JustTalDevelops Jul 22, 2022
62f9c8b
blockinternal/builder.go: Removed pointless nil checks.
JustTalDevelops Jul 22, 2022
7d12471
world/block_state.go: Remove pointless else if.
JustTalDevelops Jul 23, 2022
ac22916
customblock/geometry.go: Made UV `any` because the idiots at Mojang d…
JustTalDevelops Jul 25, 2022
b191b9e
customblock/geometry.go: Abs the cube sizes
TwistedAsylumMC Jul 25, 2022
f4b1855
server/server.go: Lazy init block and item components
TwistedAsylumMC Jul 26, 2022
efaf160
blockinternal/builder.go: Don't write multiple traits.
JustTalDevelops Jul 26, 2022
3494f10
blockinternal/builder.go: Maintain registration order.
JustTalDevelops Jul 26, 2022
786ba66
Update server/internal/blockinternal/components.go
JustTalDevelops Aug 11, 2022
e313001
Update server/world/block_state.go
JustTalDevelops Aug 11, 2022
d1e48b8
updated contributor list
JustTalDevelops Aug 11, 2022
cbdfa9b
dragonfly: Merge master into feature/custom-blocks
TwistedAsylumMC Nov 2, 2023
273b125
dragonfly: Finish custom block implementation
TwistedAsylumMC Nov 3, 2023
9ec048c
dragonfly: Cleanup custom block code
TwistedAsylumMC Nov 3, 2023
21e8df6
sliceutil/sliceutil.go: Remove Insert() in favour of slices package
TwistedAsylumMC Nov 5, 2023
884aaa5
dragonfly: Use Go 1.21 and use std slices package
TwistedAsylumMC Nov 5, 2023
7e8918c
.github/workflows: Use Go 1.21
TwistedAsylumMC Nov 5, 2023
945d56d
block/hash.go: Remove dropper hash
TwistedAsylumMC Nov 5, 2023
17073c1
leveldat/data.go: Add naturalgeneration field
TwistedAsylumMC Nov 17, 2023
79f1c57
Merge branch 'master' into feature/custom-blocks
TwistedAsylumMC Dec 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.19
- name: Set up Go 1.21
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.21
id: go

- name: Check out code into the Go module directory
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.19
- name: Set up Go 1.21
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.21
id: go

- name: Check out code into the Go module directory
Expand Down
20 changes: 18 additions & 2 deletions cmd/blockhash/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ func procPackage(pkg *ast.Package, fs *token.FileSet, w io.Writer) {

b.writePackage(w)
i := b.writeConstants(w)
b.writeNextHash(w)
b.writeMethods(w, i)
}

var (
packageFormat = "// Code generated by cmd/blockhash; DO NOT EDIT.\n\npackage %v\n\n"
methodFormat = "\nfunc (%v%v) Hash() uint64 {\n\treturn %v\n}\n"
methodFormat = "\n// Hash ...\nfunc (%v%v) Hash() uint64 {\n\treturn %v\n}\n"
constFormat = "\thash%v"
)

Expand Down Expand Up @@ -112,13 +113,28 @@ func (b *hashBuilder) writeConstants(w io.Writer) (bitSize int) {
i++
}

if _, err := fmt.Fprintln(w, ")"); err != nil {
if _, err := fmt.Fprintln(w, "\thashCustomBlockBase\n)"); err != nil {
log.Fatalln(err)
}

return bits.Len64(i)
}

func (b *hashBuilder) writeNextHash(w io.Writer) {
if _, err := fmt.Fprintln(w, "\n// customBlockBase represents the base hash for all custom blocks."); err != nil {
log.Fatalln(err)
}
if _, err := fmt.Fprintln(w, "var customBlockBase = uint64(hashCustomBlockBase - 1)"); err != nil {
log.Fatalln(err)
}
if _, err := fmt.Fprintln(w, "\n// NextHash returns the next free hash for custom blocks."); err != nil {
log.Fatalln(err)
}
if _, err := fmt.Fprintln(w, "func NextHash() uint64 {\n\tcustomBlockBase++\n\treturn customBlockBase\n}"); err != nil {
log.Fatalln(err)
}
}

func (b *hashBuilder) writeMethods(w io.Writer, baseBits int) {
for _, name := range b.names {
fields := b.blockFields[name]
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/df-mc/dragonfly

go 1.19
go 1.21

require (
github.com/brentp/intintmap v0.0.0-20190211203843-30dc0ade9af9
Expand All @@ -13,6 +13,7 @@ require (
github.com/pelletier/go-toml v1.9.5
github.com/rogpeppe/go-internal v1.9.0
github.com/sandertv/gophertunnel v1.34.0
github.com/segmentio/fasthash v1.0.3
github.com/sirupsen/logrus v1.9.0
go.uber.org/atomic v1.10.0
golang.org/x/exp v0.0.0-20230206171751-46f607a40771
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
Expand All @@ -50,13 +51,16 @@ github.com/sandertv/go-raknet v1.12.0 h1:olUzZlIJyX/pgj/mrsLCZYjKLNDsYiWdvQ4NIm3
github.com/sandertv/go-raknet v1.12.0/go.mod h1:Gx+WgZBMQ0V2UoouGoJ8Wj6CDrMBQ4SB2F/ggpl5/+Y=
github.com/sandertv/gophertunnel v1.34.0 h1:fHXTPL4+hUJFF5xObM9T07GpXkTdSvKmYAvx65k0IAw=
github.com/sandertv/gophertunnel v1.34.0/go.mod h1:+Dbhj3bs74gZoSkyab7kglx1Rbq8S5G7sJd/wr5Qm9g=
github.com/segmentio/fasthash v1.0.3 h1:EI9+KE1EwvMLBWwjpRDc+fEM+prwxDYbslddQGtrmhM=
github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
Expand Down Expand Up @@ -122,3 +126,4 @@ gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
14 changes: 13 additions & 1 deletion server/block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package block

import (
"github.com/df-mc/dragonfly/server/block/cube"
"github.com/df-mc/dragonfly/server/block/customblock"
"github.com/df-mc/dragonfly/server/block/model"
"github.com/df-mc/dragonfly/server/item"
"github.com/df-mc/dragonfly/server/world"
Expand Down Expand Up @@ -73,13 +74,24 @@ type EntityInsider interface {
EntityInside(pos cube.Pos, w *world.World, e world.Entity)
}

// Frictional represents a block that may have a custom friction value, friction is used for entity drag when the
// Frictional represents a block that may have a custom friction value. Friction is used for entity drag when the
// entity is on ground. If a block does not implement this interface, it should be assumed that its friction is 0.6.
type Frictional interface {
// Friction returns the block's friction value.
Friction() float64
}

// Permutable represents a custom block that can have more permutations than its default state.
type Permutable interface {
// States returns a map of all the different properties for the block. The key is the property name, and the value
// is a slice of all the possible values for that property. It is important that a block is registered in dragonfly
// for each of the possible combinations of properties and values.
States() map[string][]any
// Permutations returns a slice of all the different permutations for the block. Multiple permutations can be
// applied at once if their conditions are met.
Permutations() []customblock.Permutation
}

func calculateFace(user item.User, placePos cube.Pos) cube.Face {
userPos := user.Position()
pos := cube.PosFromVec3(userPos)
Expand Down
58 changes: 58 additions & 0 deletions server/block/customblock/material.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package customblock

// Material represents a single material used for rendering part of a custom block.
type Material struct {
// texture is the name of the texture for the material.
texture string
// renderMethod is the method to use when rendering the material.
renderMethod Method
// faceDimming is if the material should be dimmed by the direction it's facing.
faceDimming bool
// ambientOcclusion is if the material should have ambient occlusion applied when lighting.
ambientOcclusion bool
}

// NewMaterial returns a new Material with the provided information. It enables face dimming by default and ambient
// occlusion based on the render method given.
func NewMaterial(texture string, method Method) Material {
return Material{
texture: texture,
renderMethod: method,
faceDimming: true,
ambientOcclusion: method.AmbientOcclusion(),
}
}

// WithFaceDimming returns a copy of the Material with face dimming enabled.
func (m Material) WithFaceDimming() Material {
m.faceDimming = true
return m
}

// WithoutFaceDimming returns a copy of the Material with face dimming disabled.
func (m Material) WithoutFaceDimming() Material {
m.faceDimming = false
return m
}

// WithAmbientOcclusion returns a copy of the Material with ambient occlusion enabled.
func (m Material) WithAmbientOcclusion() Material {
m.ambientOcclusion = true
return m
}

// WithoutAmbientOcclusion returns a copy of the Material with ambient occlusion disabled.
func (m Material) WithoutAmbientOcclusion() Material {
m.ambientOcclusion = false
return m
}

// Encode returns the material encoded as a map that can be sent over the network to the client.
func (m Material) Encode() map[string]any {
return map[string]any{
"texture": m.texture,
"render_method": m.renderMethod.String(),
"face_dimming": m.faceDimming,
"ambient_occlusion": m.ambientOcclusion,
}
}
44 changes: 44 additions & 0 deletions server/block/customblock/permutations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package customblock

import (
"github.com/df-mc/dragonfly/server/block/cube"
"github.com/go-gl/mathgl/mgl64"
)

// Properties represents the different properties that can be applied to a block or a permutation.
type Properties struct {
// CollisionBox represents the bounding box of the block that the player can collide with. This cannot exceed the
// position of the current block in the world, otherwise it will be cut off at the edge.
CollisionBox cube.BBox
// Cube determines whether the block should inherit the default cube geometry. This will only be considered if the
// Geometry field is empty.
Cube bool
// Geometry represents the geometry identifier that should be used for the block. If you want to use the default
// cube geometry, leave this field empty and set Cube to true.
Geometry string
// MapColour represents the hex colour that should be used for the block on a map.
MapColour string
// Rotation represents the rotation of the block. Rotations are only applied in 90 degree increments, meaning
// 1 = 90 degrees, 2 = 180 degrees, 3 = 270 degrees and 4 = 360 degrees.
Rotation cube.Pos
// Scale is the scale of the block, with 1 being the default scale in all axes. When scaled, the block cannot
// exceed a 30x30x30 pixel area otherwise the client will not render the block.
Scale mgl64.Vec3
// SelectionBox represents the bounding box of the block that the player can interact with. This cannot exceed the
// position of the current block in the world, otherwise it will be cut off at the edge.
SelectionBox cube.BBox
// Textures define the textures that should be used for the block. The key is the target of the texture, such as
// "*" for all sides, or one of "up", "down", "north", "south", "east", "west" for a specific side.
Textures map[string]Material
// Translation is the translation of the block within itself. When translated, the block cannot exceed a 30x30x30
// pixel area otherwise the client will not render the block.
Translation mgl64.Vec3
}

// Permutation represents a specific permutation for a block that is only applied when the condition is met.
type Permutation struct {
Properties
// Condition is a molang query that is used to determine whether the permutation should be applied.
// Only the latest version of molang is supported.
Condition string
}
58 changes: 58 additions & 0 deletions server/block/customblock/render_method.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package customblock

// Method is the method to use when rendering a material for a custom block.
type Method struct {
renderMethod
}

// OpaqueRenderMethod returns the opaque rendering method for a material. It does not render an alpha layer, meaning it
// does not support transparent or translucent textures, only textures that are fully opaque.
func OpaqueRenderMethod() Method {
return Method{0}
}

// AlphaTestRenderMethod returns the alpha_test rendering method for a material. It does not allow for translucent
// textures, only textures that are fully opaque or fully transparent, used for blocks such as regular glass. It also
// disables ambient occlusion by default.
func AlphaTestRenderMethod() Method {
return Method{1}
}

// BlendRenderMethod returns the blend rendering method for a material. It allows for transparent and translucent
// textures, used for blocks such as stained-glass. It also disables ambient occlusion by default.
func BlendRenderMethod() Method {
return Method{2}
}

// DoubleSidedRenderMethod returns the double_sided rendering method for a material. It is used to completely disable
// backface culling, which would be used for flat faces visible from both sides.
func DoubleSidedRenderMethod() Method {
return Method{3}
}

type renderMethod uint8

// Uint8 returns the render method as a uint8.
func (m renderMethod) Uint8() uint8 {
return uint8(m)
}

// String ...
func (m renderMethod) String() string {
switch m {
case 0:
return "opaque"
case 1:
return "alpha_test"
case 2:
return "blend"
case 3:
return "double_sided"
}
panic("should never happen")
}

// AmbientOcclusion returns if ambient occlusion should be enabled by default for a material using this rendering method.
func (m renderMethod) AmbientOcclusion() bool {
return m != 1 && m != 2
}
Loading