-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
13 changed files
with
235 additions
and
14 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,76 @@ | ||
package block | ||
|
||
import ( | ||
"github.com/df-mc/dragonfly/server/block/cube" | ||
"github.com/df-mc/dragonfly/server/block/model" | ||
"github.com/df-mc/dragonfly/server/item" | ||
"github.com/df-mc/dragonfly/server/world" | ||
"github.com/go-gl/mathgl/mgl64" | ||
) | ||
|
||
// EndRod is a decorative light source that emits white particles. | ||
type EndRod struct { | ||
transparent | ||
flowingWaterDisplacer | ||
|
||
// Facing is the direction the white end point of the end rod is facing. | ||
Facing cube.Face | ||
} | ||
|
||
// UseOnBlock ... | ||
func (e EndRod) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, tx *world.Tx, user item.User, ctx *item.UseContext) bool { | ||
pos, face, used := firstReplaceable(tx, pos, face, e) | ||
if !used { | ||
return false | ||
} | ||
|
||
e.Facing = face | ||
if other, ok := tx.Block(pos.Side(face.Opposite())).(EndRod); ok { | ||
if face == other.Facing { | ||
e.Facing = face.Opposite() | ||
} | ||
} | ||
place(tx, pos, e, user, ctx) | ||
return placed(ctx) | ||
} | ||
|
||
// SideClosed ... | ||
func (EndRod) SideClosed(cube.Pos, cube.Pos, *world.Tx) bool { | ||
return false | ||
} | ||
|
||
// Model ... | ||
func (e EndRod) Model() world.BlockModel { | ||
return model.EndRod{Axis: e.Facing.Axis()} | ||
} | ||
|
||
// LightEmissionLevel ... | ||
func (EndRod) LightEmissionLevel() uint8 { | ||
return 14 | ||
} | ||
|
||
// BreakInfo ... | ||
func (e EndRod) BreakInfo() BreakInfo { | ||
return newBreakInfo(0, alwaysHarvestable, nothingEffective, oneOf(e)) | ||
} | ||
|
||
// EncodeItem ... | ||
func (EndRod) EncodeItem() (name string, meta int16) { | ||
return "minecraft:end_rod", 0 | ||
} | ||
|
||
// EncodeBlock ... | ||
func (e EndRod) EncodeBlock() (string, map[string]any) { | ||
if e.Facing.Axis() == cube.Y { | ||
return "minecraft:end_rod", map[string]any{"facing_direction": int32(e.Facing)} | ||
} | ||
return "minecraft:end_rod", map[string]any{"facing_direction": int32(e.Facing.Opposite())} | ||
} | ||
|
||
// allEndRods ... | ||
func allEndRods() (b []world.Block) { | ||
for _, f := range cube.Faces() { | ||
b = append(b, EndRod{Facing: f}) | ||
} | ||
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,22 @@ | ||
package model | ||
|
||
import ( | ||
"github.com/df-mc/dragonfly/server/block/cube" | ||
"github.com/df-mc/dragonfly/server/world" | ||
) | ||
|
||
// EndRod is a model used by end rod blocks. | ||
type EndRod struct { | ||
// Axis is the axis which the end rod faces. | ||
Axis cube.Axis | ||
} | ||
|
||
// BBox ... | ||
func (e EndRod) BBox(cube.Pos, world.BlockSource) []cube.BBox { | ||
return []cube.BBox{cube.Box(0.375, 0.375, 0.375, 0.625, 0.625, 0.625).Stretch(e.Axis, 0.375)} | ||
} | ||
|
||
// FaceSolid ... | ||
func (EndRod) FaceSolid(cube.Pos, cube.Face, world.BlockSource) bool { | ||
return false | ||
} |
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
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,104 @@ | ||
package block | ||
|
||
import ( | ||
"github.com/df-mc/dragonfly/server/block/cube" | ||
"github.com/df-mc/dragonfly/server/item" | ||
"github.com/df-mc/dragonfly/server/world" | ||
"github.com/go-gl/mathgl/mgl64" | ||
) | ||
|
||
// PinkPetals is a decorative block that generates in cherry grove biomes. | ||
type PinkPetals struct { | ||
empty | ||
transparent | ||
|
||
// AdditionalCount is the amount of additional pink petals. This can range | ||
// from 0-7, where only 0-3 can occur in-game. | ||
AdditionalCount int | ||
// Facing is the direction the pink petals are facing. This is opposite to | ||
// the direction the player is facing when placing. | ||
Facing cube.Direction | ||
} | ||
|
||
// BoneMeal ... | ||
func (p PinkPetals) BoneMeal(pos cube.Pos, tx *world.Tx) bool { | ||
if p.AdditionalCount < 3 { | ||
p.AdditionalCount++ | ||
tx.SetBlock(pos, p, nil) | ||
return true | ||
} | ||
dropItem(tx, item.NewStack(p, 1), pos.Vec3Centre()) | ||
return true | ||
} | ||
|
||
// UseOnBlock ... | ||
func (p PinkPetals) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, tx *world.Tx, user item.User, ctx *item.UseContext) bool { | ||
if existing, ok := tx.Block(pos).(PinkPetals); ok { | ||
if existing.AdditionalCount >= 3 { | ||
return false | ||
} | ||
|
||
existing.AdditionalCount++ | ||
place(tx, pos, existing, user, ctx) | ||
return placed(ctx) | ||
} | ||
|
||
pos, _, used := firstReplaceable(tx, pos, face, p) | ||
if !used { | ||
return false | ||
} | ||
if !supportsVegetation(p, tx.Block(pos.Side(cube.FaceDown))) { | ||
return false | ||
} | ||
|
||
p.Facing = user.Rotation().Direction().Opposite() | ||
place(tx, pos, p, user, ctx) | ||
return placed(ctx) | ||
} | ||
|
||
// NeighbourUpdateTick ... | ||
func (p PinkPetals) NeighbourUpdateTick(pos, _ cube.Pos, tx *world.Tx) { | ||
if !supportsVegetation(p, tx.Block(pos.Side(cube.FaceDown))) { | ||
breakBlock(p, pos, tx) | ||
} | ||
} | ||
|
||
// HasLiquidDrops ... | ||
func (PinkPetals) HasLiquidDrops() bool { | ||
return true | ||
} | ||
|
||
// BreakInfo ... | ||
func (p PinkPetals) BreakInfo() BreakInfo { | ||
return newBreakInfo(0, alwaysHarvestable, nothingEffective, simpleDrops(item.NewStack(p, p.AdditionalCount+1))) | ||
} | ||
|
||
// FlammabilityInfo ... | ||
func (p PinkPetals) FlammabilityInfo() FlammabilityInfo { | ||
return newFlammabilityInfo(30, 100, true) | ||
} | ||
|
||
// CompostChance ... | ||
func (PinkPetals) CompostChance() float64 { | ||
return 0.3 | ||
} | ||
|
||
// EncodeItem ... | ||
func (PinkPetals) EncodeItem() (name string, meta int16) { | ||
return "minecraft:pink_petals", 0 | ||
} | ||
|
||
// EncodeBlock ... | ||
func (p PinkPetals) EncodeBlock() (string, map[string]any) { | ||
return "minecraft:pink_petals", map[string]any{"growth": int32(p.AdditionalCount), "minecraft:cardinal_direction": p.Facing.String()} | ||
} | ||
|
||
// allPinkPetals ... | ||
func allPinkPetals() (b []world.Block) { | ||
for i := 0; i <= 7; i++ { | ||
for _, d := range cube.Directions() { | ||
b = append(b, PinkPetals{AdditionalCount: i, Facing: d}) | ||
} | ||
} | ||
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
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