Skip to content

Commit

Permalink
server/block: Implement missing tuff blocks & fix some slab/stairs br…
Browse files Browse the repository at this point in the history
…eak info
  • Loading branch information
TwistedAsylumMC committed Nov 16, 2024
1 parent 16b4c61 commit 4064d73
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 8 deletions.
14 changes: 12 additions & 2 deletions server/block/hash.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions server/block/polished_tuff.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package block

// PolishedTuff is a decorational variant of Tuff that can be crafted or found naturally in Trial Chambers.
type PolishedTuff struct {
solid
bassDrum
}

// BreakInfo ...
func (t PolishedTuff) BreakInfo() BreakInfo {
return newBreakInfo(1.5, pickaxeHarvestable, pickaxeEffective, oneOf(t)).withBlastResistance(30)
}

// EncodeItem ...
func (t PolishedTuff) EncodeItem() (name string, meta int16) {
return "minecraft:polished_tuff", 0
}

// EncodeBlock ...
func (t PolishedTuff) EncodeBlock() (string, map[string]any) {
return "minecraft:polished_tuff", nil
}
8 changes: 8 additions & 0 deletions server/block/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ func init() {
world.RegisterBlock(TNT{})
world.RegisterBlock(Terracotta{})
world.RegisterBlock(Tuff{})
world.RegisterBlock(Tuff{Chiseled: true})
world.RegisterBlock(TuffBricks{})
world.RegisterBlock(TuffBricks{Chiseled: true})
world.RegisterBlock(PolishedTuff{})
world.RegisterBlock(ShortGrass{})
world.RegisterBlock(Fern{})

Expand Down Expand Up @@ -331,6 +335,10 @@ func init() {
world.RegisterItem(TNT{})
world.RegisterItem(Terracotta{})
world.RegisterItem(Tuff{})
world.RegisterItem(Tuff{Chiseled: true})
world.RegisterItem(TuffBricks{})
world.RegisterItem(TuffBricks{Chiseled: true})
world.RegisterItem(PolishedTuff{})
world.RegisterItem(WheatSeeds{})
world.RegisterItem(DecoratedPot{})
world.RegisterItem(ShortGrass{})
Expand Down
5 changes: 4 additions & 1 deletion server/block/slab.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ func (s Slab) BreakInfo() BreakInfo {

switch block := s.Block.(type) {
// TODO: Copper
// TODO: Deepslate
case Deepslate, DeepslateBricks, DeepslateTiles:
hardness = 3.5
case EndBricks:
hardness = 3.0
blastResistance = 45.0
Expand All @@ -135,6 +136,8 @@ func (s Slab) BreakInfo() BreakInfo {
harvestable = alwaysHarvestable
effective = axeEffective
blastResistance = 15.0
case Tuff, PolishedTuff:
hardness = 1.5
}
return newBreakInfo(hardness, harvestable, effective, func(tool item.Tool, enchantments []item.Enchantment) []item.Stack {
if s.Double {
Expand Down
12 changes: 11 additions & 1 deletion server/block/slab_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ func encodeSlabBlock(block world.Block) (id string) {
if !block.Cracked {
return "polished_blackstone_brick"
}
case PolishedTuff:
return "polished_tuff"
case Prismarine:
switch block.Type {
case NormalPrismarine():
Expand Down Expand Up @@ -114,7 +116,13 @@ func encodeSlabBlock(block world.Block) (id string) {
}
return "stone_brick"
case Tuff:
return "tuff"
if !block.Chiseled {
return "tuff"
}
case TuffBricks:
if !block.Chiseled {
return "tuff_brick"
}
}
panic("invalid block used for slab")
}
Expand Down Expand Up @@ -143,6 +151,7 @@ func SlabBlocks() []world.Block {
NetherBricks{Type: RedNetherBricks()},
NetherBricks{},
PolishedBlackstoneBrick{},
PolishedTuff{},
Purpur{},
Quartz{Smooth: true},
Quartz{},
Expand All @@ -151,6 +160,7 @@ func SlabBlocks() []world.Block {
Stone{Smooth: true},
Stone{},
Tuff{},
TuffBricks{},
}
for _, p := range PrismarineTypes() {
b = append(b, Prismarine{Type: p})
Expand Down
8 changes: 6 additions & 2 deletions server/block/stairs.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ func (s Stairs) BreakInfo() BreakInfo {

switch block := s.Block.(type) {
// TODO: Copper
// TODO: Blackstone
// TODO: Deepslate
case Blackstone:
hardness = 1.5
case Deepslate, DeepslateBricks, DeepslateTiles:
hardness = 3.5
case Planks:
harvestable = alwaysHarvestable
effective = axeEffective
Expand All @@ -75,6 +77,8 @@ func (s Stairs) BreakInfo() BreakInfo {
if block.Type == NormalStoneBricks() {
hardness = 1.5
}
case Tuff, PolishedTuff:
hardness = 1.5
}
return newBreakInfo(hardness, harvestable, effective, oneOf(s)).withBlastResistance(blastResistance)
}
Expand Down
12 changes: 11 additions & 1 deletion server/block/stairs_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ func encodeStairsBlock(block world.Block) string {
if !block.Cracked {
return "polished_blackstone_brick"
}
case PolishedTuff:
return "polished_tuff"
case Prismarine:
switch block.Type {
case NormalPrismarine():
Expand Down Expand Up @@ -106,7 +108,13 @@ func encodeStairsBlock(block world.Block) string {
}
return "stone_brick"
case Tuff:
return "tuff"
if !block.Chiseled {
return "tuff"
}
case TuffBricks:
if !block.Chiseled {
return "tuff_brick"
}
}
panic("invalid block used for stairs")
}
Expand Down Expand Up @@ -135,13 +143,15 @@ func StairsBlocks() []world.Block {
NetherBricks{Type: RedNetherBricks()},
NetherBricks{},
PolishedBlackstoneBrick{},
PolishedTuff{},
Purpur{},
Quartz{Smooth: true},
Quartz{},
StoneBricks{Type: MossyStoneBricks()},
StoneBricks{},
Stone{},
Tuff{},
TuffBricks{},
}
for _, p := range PrismarineTypes() {
b = append(b, Prismarine{Type: p})
Expand Down
9 changes: 9 additions & 0 deletions server/block/tuff.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ package block
type Tuff struct {
solid
bassDrum

// Chiseled specifies if the tuff is chiseled.
Chiseled bool
}

// BreakInfo ...
Expand All @@ -13,10 +16,16 @@ func (t Tuff) BreakInfo() BreakInfo {

// EncodeItem ...
func (t Tuff) EncodeItem() (name string, meta int16) {
if t.Chiseled {
return "minecraft:chiseled_tuff", 0
}
return "minecraft:tuff", 0
}

// EncodeBlock ...
func (t Tuff) EncodeBlock() (string, map[string]any) {
if t.Chiseled {
return "minecraft:chiseled_tuff", nil
}
return "minecraft:tuff", nil
}
31 changes: 31 additions & 0 deletions server/block/tuff_bricks.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package block

// TuffBricks are a decorational variant of Tuff that can be crafted or found naturally in Trial Chambers.
type TuffBricks struct {
solid
bassDrum

// Chiseled specifies if the tuff bricks are chiseled.
Chiseled bool
}

// BreakInfo ...
func (t TuffBricks) BreakInfo() BreakInfo {
return newBreakInfo(1.5, pickaxeHarvestable, pickaxeEffective, oneOf(t)).withBlastResistance(30)
}

// EncodeItem ...
func (t TuffBricks) EncodeItem() (name string, meta int16) {
if t.Chiseled {
return "minecraft:chiseled_tuff_bricks", 0
}
return "minecraft:tuff_bricks", 0
}

// EncodeBlock ...
func (t TuffBricks) EncodeBlock() (string, map[string]any) {
if t.Chiseled {
return "minecraft:chiseled_tuff_bricks", nil
}
return "minecraft:tuff_bricks", nil
}
12 changes: 11 additions & 1 deletion server/block/wall_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ func encodeWallBlock(block world.Block) string {
if !block.Cracked {
return "polished_blackstone_brick"
}
case PolishedTuff:
return "polished_tuff"
case Prismarine:
if block.Type == NormalPrismarine() {
return "prismarine"
Expand All @@ -76,7 +78,13 @@ func encodeWallBlock(block world.Block) string {
return "mossy_stone_brick"
}
case Tuff:
return "tuff"
if !block.Chiseled {
return "tuff"
}
case TuffBricks:
if !block.Chiseled {
return "tuff_brick"
}
}
panic("invalid block used for wall")
}
Expand All @@ -101,11 +109,13 @@ func WallBlocks() []world.Block {
NetherBricks{Type: RedNetherBricks()},
NetherBricks{},
PolishedBlackstoneBrick{},
PolishedTuff{},
Prismarine{},
Sandstone{Red: true},
Sandstone{},
StoneBricks{Type: MossyStoneBricks()},
StoneBricks{},
Tuff{},
TuffBricks{},
}
}

0 comments on commit 4064d73

Please sign in to comment.