forked from df-mc/dragonfly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enchanting_table.go
66 lines (55 loc) · 1.91 KB
/
enchanting_table.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
package block
import (
"github.com/Adrian8115/dragonfly-Amethyst-Protocol/server/block/cube"
"github.com/Adrian8115/dragonfly-Amethyst-Protocol/server/block/model"
"github.com/Adrian8115/dragonfly-Amethyst-Protocol/server/item"
"github.com/Adrian8115/dragonfly-Amethyst-Protocol/server/world"
)
// EnchantingTable is a block that allows players to spend their experience point levels to enchant tools, weapons,
// books, armor, and certain other items.
type EnchantingTable struct {
transparent
bassDrum
sourceWaterDisplacer
}
// Model ...
func (e EnchantingTable) Model() world.BlockModel {
return model.EnchantingTable{}
}
// BreakInfo ...
func (e EnchantingTable) BreakInfo() BreakInfo {
return newBreakInfo(5, pickaxeHarvestable, pickaxeEffective, oneOf(e)).withBlastResistance(6000)
}
// SideClosed ...
func (EnchantingTable) SideClosed(cube.Pos, cube.Pos, *world.World) bool {
return false
}
// LightEmissionLevel ...
func (EnchantingTable) LightEmissionLevel() uint8 {
return 7
}
// Activate ...
func (EnchantingTable) Activate(pos cube.Pos, _ cube.Face, _ *world.World, u item.User, _ *item.UseContext) bool {
if opener, ok := u.(ContainerOpener); ok {
opener.OpenBlockContainer(pos)
return true
}
return false
}
// EncodeItem ...
func (EnchantingTable) EncodeItem() (name string, meta int16) {
return "minecraft:enchanting_table", 0
}
// EncodeBlock ...
func (EnchantingTable) EncodeBlock() (string, map[string]any) {
return "minecraft:enchanting_table", nil
}
// EncodeNBT is used to encode the block to NBT, so that the enchanting table book will be rendered properly client-side.
// The actual rotation value doesn't need to be set in the NBT, we just need to write the default NBT for the block.
func (e EnchantingTable) EncodeNBT() map[string]any {
return map[string]any{"id": "EnchantTable"}
}
// DecodeNBT is used to implement world.NBTer.
func (e EnchantingTable) DecodeNBT(map[string]any) any {
return e
}