Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions server/block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ type LightDiffuser interface {
LightDiffusionLevel() uint8
}

// NonSuffocating represents a block that, despite being fully solid, never suffocates an entity standing
// inside it. This is distinct from LightDiffuser: a block may block all light while still being safe to
// stand inside, such as tinted glass.
type NonSuffocating interface {
// SuffocationImmune returns true if the block never causes suffocation damage to entities inside it.
SuffocationImmune() bool
}

// RedstoneWireStepDowner represents a block with custom behaviour for redstone wire providing power when travelling
// down it.
type RedstoneWireStepDowner interface {
Expand Down
5 changes: 5 additions & 0 deletions server/block/hash.go

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

2 changes: 2 additions & 0 deletions server/block/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func init() {
world.RegisterBlock(PolishedSulfur{})
world.RegisterBlock(TNT{})
world.RegisterBlock(Terracotta{})
world.RegisterBlock(TintedGlass{})
world.RegisterBlock(Tuff{})
world.RegisterBlock(Tuff{Chiseled: true})
world.RegisterBlock(TuffBricks{})
Expand Down Expand Up @@ -429,6 +430,7 @@ func init() {
world.RegisterItem(PolishedSulfur{})
world.RegisterItem(TNT{})
world.RegisterItem(Terracotta{})
world.RegisterItem(TintedGlass{})
world.RegisterItem(Tuff{})
world.RegisterItem(Tuff{Chiseled: true})
world.RegisterItem(TuffBricks{})
Expand Down
29 changes: 29 additions & 0 deletions server/block/tinted_glass.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package block

// TintedGlass is a decorative, solid block that is visually see-through but, unlike regular glass, blocks
// all light passing through it.
type TintedGlass struct {
solid
clicksAndSticks
}

// SuffocationImmune always returns true. Tinted glass blocks light entirely but, like regular glass, never
// suffocates an entity standing inside it.
func (TintedGlass) SuffocationImmune() bool {
return true
}

// BreakInfo ...
func (g TintedGlass) BreakInfo() BreakInfo {
return newBreakInfo(0.3, alwaysHarvestable, nothingEffective, oneOf(g)).withBlastResistance(0.3)
}

// EncodeItem ...
func (TintedGlass) EncodeItem() (name string, meta int16) {
return "minecraft:tinted_glass", 0
}

// EncodeBlock ...
func (TintedGlass) EncodeBlock() (string, map[string]any) {
return "minecraft:tinted_glass", nil
}
3 changes: 3 additions & 0 deletions server/player/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -2844,6 +2844,9 @@ func (p *Player) insideOfSolid() bool {
// Transparent.
return false
}
if immune, ok := b.(block.NonSuffocating); ok && immune.SuffocationImmune() {
return false
}
for _, blockBox := range b.Model().BBox(pos, p.tx) {
if blockBox.Translate(pos.Vec3()).IntersectsWith(box) {
return true
Expand Down