forked from df-mc/dragonfly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
slab_type.go
180 lines (176 loc) · 4.66 KB
/
slab_type.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
package block
import (
"github.com/Adrian8115/dragonfly-Amethyst-Protocol/server/world"
)
// encodeSlabBlock encodes the provided block in to an identifier and meta value that can be used to encode the slab.
func encodeSlabBlock(block world.Block) (id, slabType string, meta int16) {
switch block := block.(type) {
// TODO: Copper
case Andesite:
if block.Polished {
return "polished_andesite", "stone_slab_type_3", 2
}
return "andesite", "stone_slab_type_3", 3
case Blackstone:
if block.Type == NormalBlackstone() {
return "blackstone", "", 0
} else if block.Type == PolishedBlackstone() {
return "polished_blackstone", "", 0
}
case Bricks:
return "brick", "stone_slab_type", 4
case Cobblestone:
if block.Mossy {
return "mossy_cobblestone", "stone_slab_type_2", 5
}
return "cobblestone", "stone_slab_type", 3
case Deepslate:
if block.Type == CobbledDeepslate() {
return "cobbled_deepslate", "", 0
} else if block.Type == PolishedDeepslate() {
return "polished_deepslate", "", 0
}
case DeepslateBricks:
if !block.Cracked {
return "deepslate_brick", "", 0
}
case DeepslateTiles:
if !block.Cracked {
return "deepslate_tile", "", 0
}
case Diorite:
if block.Polished {
return "polished_diorite", "stone_slab_type_3", 5
}
return "diorite", "stone_slab_type_3", 4
case EndBricks:
return "end_stone_brick", "stone_slab_type_3", 0
case Granite:
if block.Polished {
return "polished_granite", "stone_slab_type_3", 7
}
return "granite", "stone_slab_type_3", 6
case MudBricks:
return "mud_brick", "", 0
case NetherBricks:
if block.Type == RedNetherBricks() {
return "nether_brick", "stone_slab_type", 7
}
return "red_nether_brick", "stone_slab_type_2", 7
case Planks:
return block.Wood.String(), "", 0
case PolishedBlackstoneBrick:
if !block.Cracked {
return "polished_blackstone_brick", "", 0
}
case Prismarine:
switch block.Type {
case NormalPrismarine():
return "prismarine_rough", "stone_slab_type_2", 2
case DarkPrismarine():
return "prismarine_dark", "stone_slab_type_2", 3
case BrickPrismarine():
return "prismarine_brick", "stone_slab_type_2", 4
}
panic("invalid prismarine type")
case Purpur:
return "purpur", "stone_slab_type_2", 1
case Quartz:
if block.Smooth {
return "smooth_quartz", "stone_slab_type_4", 1
}
return "quartz", "stone_slab_type", 6
case Sandstone:
switch block.Type {
case NormalSandstone():
if block.Red {
return "red_sandstone", "stone_slab_type_2", 0
}
return "sandstone", "stone_slab_type", 1
case CutSandstone():
if block.Red {
return "cut_red_sandstone", "stone_slab_type_4", 4
}
return "cut_sandstone", "stone_slab_type_4", 3
case SmoothSandstone():
if block.Red {
return "smooth_red_sandstone", "stone_slab_type_3", 1
}
return "smooth_sandstone", "stone_slab_type_2", 6
}
panic("invalid sandstone type")
case Stone:
if block.Smooth {
return "smooth_stone", "stone_slab_type", 0
}
return "stone", "stone_slab_type_4", 2
case StoneBricks:
if block.Type == MossyStoneBricks() {
return "mossy_stone_brick", "stone_slab_type_4", 0
}
return "stone_brick", "stone_slab_type", 5
}
panic("invalid block used for slab")
}
// encodeLegacySlabId encodes a legacy slab type to its identifier.
func encodeLegacySlabId(slabType string) string {
switch slabType {
case "wood_type":
return "wooden_slab"
case "stone_slab_type":
return "stone_block_slab"
case "stone_slab_type_2":
return "stone_block_slab2"
case "stone_slab_type_3":
return "stone_block_slab3"
case "stone_slab_type_4":
return "stone_block_slab4"
}
panic("invalid slab type")
}
// SlabBlocks returns a list of all possible blocks for a slab.
func SlabBlocks() []world.Block {
b := []world.Block{
// TODO: Copper
Andesite{Polished: true},
Andesite{},
Blackstone{Type: PolishedBlackstone()},
Blackstone{},
Bricks{},
Cobblestone{Mossy: true},
Cobblestone{},
DeepslateBricks{},
DeepslateTiles{},
Deepslate{Type: CobbledDeepslate()},
Deepslate{Type: PolishedDeepslate()},
Diorite{Polished: true},
Diorite{},
EndBricks{},
Granite{Polished: true},
Granite{},
MudBricks{},
NetherBricks{Type: RedNetherBricks()},
NetherBricks{},
PolishedBlackstoneBrick{},
Purpur{},
Quartz{Smooth: true},
Quartz{},
StoneBricks{Type: MossyStoneBricks()},
StoneBricks{},
Stone{Smooth: true},
Stone{},
}
for _, p := range PrismarineTypes() {
b = append(b, Prismarine{Type: p})
}
for _, s := range SandstoneTypes() {
if s != ChiseledSandstone() {
b = append(b, Sandstone{Type: s})
b = append(b, Sandstone{Type: s, Red: true})
}
}
for _, w := range WoodTypes() {
b = append(b, Planks{Wood: w})
}
return b
}