-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server/block: Implemented Blackstone & Deepslate (#611)
- Loading branch information
1 parent
8354c72
commit dd2b96d
Showing
12 changed files
with
413 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package block | ||
|
||
import ( | ||
"github.com/df-mc/dragonfly/server/item" | ||
"github.com/df-mc/dragonfly/server/world" | ||
"math/rand" | ||
) | ||
|
||
// Blackstone is a naturally generating block in the nether that can be used to craft stone tools, brewing stands and | ||
// furnances. Gilded blackstone also has a 10% chance to drop 2-6 golden nuggets. | ||
type Blackstone struct { | ||
solid | ||
bassDrum | ||
|
||
// Type is the type of blackstone of the block. | ||
Type BlackstoneType | ||
} | ||
|
||
// BreakInfo ... | ||
func (b Blackstone) BreakInfo() BreakInfo { | ||
hardness := 1.5 | ||
drops := oneOf(b) | ||
if b.Type == GildedBlackstone() { | ||
drops = func(item.Tool, []item.Enchantment) []item.Stack { | ||
if rand.Float64() < 0.1 { | ||
return []item.Stack{item.NewStack(item.GoldNugget{}, rand.Intn(4)+2)} | ||
} | ||
return []item.Stack{item.NewStack(b, 1)} | ||
} | ||
} | ||
return newBreakInfo(hardness, pickaxeHarvestable, pickaxeEffective, drops).withBlastResistance(30) | ||
} | ||
|
||
// EncodeItem ... | ||
func (b Blackstone) EncodeItem() (name string, meta int16) { | ||
return "minecraft:" + b.Type.String(), 0 | ||
} | ||
|
||
// EncodeBlock ... | ||
func (b Blackstone) EncodeBlock() (string, map[string]any) { | ||
return "minecraft:" + b.Type.String(), nil | ||
} | ||
|
||
// allBlackstone returns a list of all blackstone block variants. | ||
func allBlackstone() (s []world.Block) { | ||
for _, t := range BlackstoneTypes() { | ||
s = append(s, Blackstone{Type: t}) | ||
} | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package block | ||
|
||
// BlackstoneType represents a type of blackstone. | ||
type BlackstoneType struct { | ||
blackstone | ||
} | ||
|
||
type blackstone uint8 | ||
|
||
// NormalBlackstone is the normal variant of blackstone. | ||
func NormalBlackstone() BlackstoneType { | ||
return BlackstoneType{0} | ||
} | ||
|
||
// GildedBlackstone is the gilded variant of blackstone. | ||
func GildedBlackstone() BlackstoneType { | ||
return BlackstoneType{1} | ||
} | ||
|
||
// PolishedBlackstone is the polished variant of blackstone. | ||
func PolishedBlackstone() BlackstoneType { | ||
return BlackstoneType{2} | ||
} | ||
|
||
// ChiseledPolishedBlackstone is the chiseled polished variant of blackstone. | ||
func ChiseledPolishedBlackstone() BlackstoneType { | ||
return BlackstoneType{3} | ||
} | ||
|
||
// Uint8 returns the blackstone type as a uint8. | ||
func (s blackstone) Uint8() uint8 { | ||
return uint8(s) | ||
} | ||
|
||
// Name ... | ||
func (s blackstone) Name() string { | ||
switch s { | ||
case 0: | ||
return "Blackstone" | ||
case 1: | ||
return "Gilded Blackstone" | ||
case 2: | ||
return "Polished Blackstone" | ||
case 3: | ||
return "Chiseled Polished Blackstone" | ||
} | ||
panic("unknown blackstone type") | ||
} | ||
|
||
// String ... | ||
func (s blackstone) String() string { | ||
switch s { | ||
case 0: | ||
return "blackstone" | ||
case 1: | ||
return "gilded_blackstone" | ||
case 2: | ||
return "polished_blackstone" | ||
case 3: | ||
return "chiseled_polished_blackstone" | ||
} | ||
panic("unknown blackstone type") | ||
} | ||
|
||
// BlackstoneTypes ... | ||
func BlackstoneTypes() []BlackstoneType { | ||
return []BlackstoneType{NormalBlackstone(), GildedBlackstone(), PolishedBlackstone(), ChiseledPolishedBlackstone()} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package block | ||
|
||
import ( | ||
"github.com/df-mc/dragonfly/server/block/cube" | ||
"github.com/df-mc/dragonfly/server/world" | ||
) | ||
|
||
// Deepslate is similar to stone but is naturally found deep underground around Y0 and below, and is harder to break. | ||
type Deepslate struct { | ||
solid | ||
bassDrum | ||
|
||
// Type is the type of deepslate of the block. | ||
Type DeepslateType | ||
// Axis is the axis which the deepslate faces. | ||
Axis cube.Axis | ||
} | ||
|
||
// BreakInfo ... | ||
func (b Deepslate) BreakInfo() BreakInfo { | ||
hardness := 3.5 | ||
if b.Type == NormalDeepslate() { | ||
hardness = 3 | ||
} | ||
return newBreakInfo(hardness, pickaxeHarvestable, pickaxeEffective, oneOf(b)).withBlastResistance(18) | ||
} | ||
|
||
// EncodeItem ... | ||
func (b Deepslate) EncodeItem() (name string, meta int16) { | ||
return "minecraft:" + b.Type.String(), 0 | ||
} | ||
|
||
// EncodeBlock ... | ||
func (b Deepslate) EncodeBlock() (string, map[string]any) { | ||
if b.Type == NormalDeepslate() { | ||
return "minecraft:deepslate", map[string]any{"pillar_axis": b.Axis.String()} | ||
} | ||
return "minecraft:" + b.Type.String(), nil | ||
} | ||
|
||
// allDeepslate returns a list of all deepslate block variants. | ||
func allDeepslate() (s []world.Block) { | ||
for _, t := range DeepslateTypes() { | ||
s = append(s, Deepslate{Type: t}) | ||
} | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package block | ||
|
||
// DeepslateBricks are a brick variant of deepslate and can spawn in ancient cities. | ||
type DeepslateBricks struct { | ||
solid | ||
bassDrum | ||
|
||
// Cracked specifies if the deepslate bricks is its cracked variant. | ||
Cracked bool | ||
} | ||
|
||
// BreakInfo ... | ||
func (d DeepslateBricks) BreakInfo() BreakInfo { | ||
return newBreakInfo(3.5, pickaxeHarvestable, pickaxeEffective, oneOf(d)).withBlastResistance(18) | ||
} | ||
|
||
// EncodeItem ... | ||
func (d DeepslateBricks) EncodeItem() (name string, meta int16) { | ||
if d.Cracked { | ||
return "minecraft:cracked_deepslate_bricks", 0 | ||
} | ||
return "minecraft:deepslate_bricks", 0 | ||
} | ||
|
||
// EncodeBlock ... | ||
func (d DeepslateBricks) EncodeBlock() (string, map[string]any) { | ||
if d.Cracked { | ||
return "minecraft:cracked_deepslate_bricks", nil | ||
} | ||
return "minecraft:deepslate_bricks", nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package block | ||
|
||
// DeepslateTiles are a tiled variant of deepslate and can spawn in ancient cities. | ||
type DeepslateTiles struct { | ||
solid | ||
bassDrum | ||
|
||
// Cracked specifies if the deepslate tiles is its cracked variant. | ||
Cracked bool | ||
} | ||
|
||
// BreakInfo ... | ||
func (d DeepslateTiles) BreakInfo() BreakInfo { | ||
return newBreakInfo(3.5, pickaxeHarvestable, pickaxeEffective, oneOf(d)).withBlastResistance(18) | ||
} | ||
|
||
// EncodeItem ... | ||
func (d DeepslateTiles) EncodeItem() (name string, meta int16) { | ||
if d.Cracked { | ||
return "minecraft:cracked_deepslate_tiles", 0 | ||
} | ||
return "minecraft:deepslate_tiles", 0 | ||
} | ||
|
||
// EncodeBlock ... | ||
func (d DeepslateTiles) EncodeBlock() (string, map[string]any) { | ||
if d.Cracked { | ||
return "minecraft:cracked_deepslate_tiles", nil | ||
} | ||
return "minecraft:deepslate_tiles", nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package block | ||
|
||
// DeepslateType represents a type of deepslate. | ||
type DeepslateType struct { | ||
deepslate | ||
} | ||
|
||
type deepslate uint8 | ||
|
||
// NormalDeepslate is the normal variant of deepslate. | ||
func NormalDeepslate() DeepslateType { | ||
return DeepslateType{0} | ||
} | ||
|
||
// CobbledDeepslate is the cobbled variant of deepslate. | ||
func CobbledDeepslate() DeepslateType { | ||
return DeepslateType{1} | ||
} | ||
|
||
// PolishedDeepslate is the polished variant of deepslate. | ||
func PolishedDeepslate() DeepslateType { | ||
return DeepslateType{2} | ||
} | ||
|
||
// ChiseledDeepslate is the chiseled variant of deepslate. | ||
func ChiseledDeepslate() DeepslateType { | ||
return DeepslateType{3} | ||
} | ||
|
||
// Uint8 returns the deepslate type as a uint8. | ||
func (s deepslate) Uint8() uint8 { | ||
return uint8(s) | ||
} | ||
|
||
// Name ... | ||
func (s deepslate) Name() string { | ||
switch s { | ||
case 0: | ||
return "Deepslate" | ||
case 1: | ||
return "Cobbled Deepslate" | ||
case 2: | ||
return "Polished Deepslate" | ||
case 3: | ||
return "Chiseled Deepslate" | ||
} | ||
panic("unknown deepslate type") | ||
} | ||
|
||
// String ... | ||
func (s deepslate) String() string { | ||
switch s { | ||
case 0: | ||
return "deepslate" | ||
case 1: | ||
return "cobbled_deepslate" | ||
case 2: | ||
return "polished_deepslate" | ||
case 3: | ||
return "chiseled_deepslate" | ||
} | ||
panic("unknown deepslate type") | ||
} | ||
|
||
// DeepslateTypes ... | ||
func DeepslateTypes() []DeepslateType { | ||
return []DeepslateType{NormalDeepslate(), CobbledDeepslate(), PolishedDeepslate(), ChiseledDeepslate()} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.