-
Notifications
You must be signed in to change notification settings - Fork 142
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 'upstream/master' into map-item
- Loading branch information
Showing
349 changed files
with
10,872 additions
and
3,757 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
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
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,21 @@ | ||
package block | ||
|
||
// Amethyst is a decorative block crafted from four amethyst shards. | ||
type Amethyst struct { | ||
solid | ||
} | ||
|
||
// BreakInfo ... | ||
func (a Amethyst) BreakInfo() BreakInfo { | ||
return newBreakInfo(1.5, pickaxeHarvestable, pickaxeHarvestable, oneOf(a)) | ||
} | ||
|
||
// EncodeItem ... | ||
func (Amethyst) EncodeItem() (name string, meta int16) { | ||
return "minecraft:amethyst_block", 0 | ||
} | ||
|
||
// EncodeBlock ... | ||
func (Amethyst) EncodeBlock() (string, map[string]any) { | ||
return "minecraft:amethyst_block", nil | ||
} |
This file was deleted.
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,103 @@ | ||
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/df-mc/dragonfly/server/world/sound" | ||
"github.com/go-gl/mathgl/mgl64" | ||
) | ||
|
||
// Anvil is a block that allows players to repair items, rename items, and combine enchantments. | ||
type Anvil struct { | ||
gravityAffected | ||
transparent | ||
|
||
// Type is the type of anvil. | ||
Type AnvilType | ||
// Facing is the direction that the anvil is facing. | ||
Facing cube.Direction | ||
} | ||
|
||
// Model ... | ||
func (a Anvil) Model() world.BlockModel { | ||
return model.Anvil{Facing: a.Facing} | ||
} | ||
|
||
// BreakInfo ... | ||
func (a Anvil) BreakInfo() BreakInfo { | ||
return newBreakInfo(5, pickaxeHarvestable, pickaxeEffective, oneOf(a)) | ||
} | ||
|
||
// Activate ... | ||
func (Anvil) Activate(pos cube.Pos, _ cube.Face, _ *world.World, u item.User) bool { | ||
if opener, ok := u.(ContainerOpener); ok { | ||
opener.OpenBlockContainer(pos) | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
// UseOnBlock ... | ||
func (a Anvil) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world.World, user item.User, ctx *item.UseContext) (used bool) { | ||
pos, _, used = firstReplaceable(w, pos, face, a) | ||
if !used { | ||
return | ||
} | ||
a.Facing = user.Facing().RotateRight() | ||
place(w, pos, a, user, ctx) | ||
return placed(ctx) | ||
} | ||
|
||
// NeighbourUpdateTick ... | ||
func (a Anvil) NeighbourUpdateTick(pos, _ cube.Pos, w *world.World) { | ||
a.fall(a, pos, w) | ||
} | ||
|
||
// Damage returns the damage per block fallen of the anvil and the maximum damage the anvil can deal. | ||
func (Anvil) Damage() (damagePerBlock, maxDamage float64) { | ||
return 2, 40 | ||
} | ||
|
||
// Break breaks the anvil and moves it to the next damage stage. If the anvil is at the last damage stage, it will be | ||
// destroyed. | ||
func (a Anvil) Break() world.Block { | ||
switch a.Type { | ||
case UndamagedAnvil(): | ||
a.Type = SlightlyDamagedAnvil() | ||
case SlightlyDamagedAnvil(): | ||
a.Type = VeryDamagedAnvil() | ||
case VeryDamagedAnvil(): | ||
return Air{} | ||
} | ||
return a | ||
} | ||
|
||
// Landed is called when a falling anvil hits the ground, used to, for example, play a sound. | ||
func (Anvil) Landed(w *world.World, pos cube.Pos) { | ||
w.PlaySound(pos.Vec3Centre(), sound.AnvilLand{}) | ||
} | ||
|
||
// EncodeItem ... | ||
func (a Anvil) EncodeItem() (name string, meta int16) { | ||
return "minecraft:anvil", int16(a.Type.Uint8()) | ||
} | ||
|
||
// EncodeBlock ... | ||
func (a Anvil) EncodeBlock() (string, map[string]any) { | ||
return "minecraft:anvil", map[string]any{ | ||
"damage": a.Type.String(), | ||
"direction": int32(horizontalDirection(a.Facing)), | ||
} | ||
} | ||
|
||
// allAnvils ... | ||
func allAnvils() (anvils []world.Block) { | ||
for _, t := range AnvilTypes() { | ||
for _, d := range cube.Directions() { | ||
anvils = append(anvils, Anvil{Type: t, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package block | ||
|
||
// AnvilType represents a type of anvil, such as undamaged, slightly damaged, or very damaged. | ||
type AnvilType struct { | ||
anvil | ||
} | ||
|
||
// UndamagedAnvil returns the undamaged anvil type. | ||
func UndamagedAnvil() AnvilType { | ||
return AnvilType{0} | ||
} | ||
|
||
// SlightlyDamagedAnvil returns the slightly damaged anvil type. | ||
func SlightlyDamagedAnvil() AnvilType { | ||
return AnvilType{1} | ||
} | ||
|
||
// VeryDamagedAnvil returns the very damaged anvil type. | ||
func VeryDamagedAnvil() AnvilType { | ||
return AnvilType{2} | ||
} | ||
|
||
// AnvilTypes returns all anvil types. | ||
func AnvilTypes() []AnvilType { | ||
return []AnvilType{UndamagedAnvil(), SlightlyDamagedAnvil(), VeryDamagedAnvil()} | ||
} | ||
|
||
type anvil uint8 | ||
|
||
// Uint8 returns the anvil type as a uint8. | ||
func (a anvil) Uint8() uint8 { | ||
return uint8(a) | ||
} | ||
|
||
// String returns the anvil type as a string. | ||
func (a anvil) String() string { | ||
switch a { | ||
case 0: | ||
return "undamaged" | ||
case 1: | ||
return "slightly_damaged" | ||
case 2: | ||
return "very_damaged" | ||
} | ||
panic("should never happen") | ||
} |
Oops, something went wrong.