Skip to content

Commit

Permalink
Merge branch 'df-mc:master' into totem
Browse files Browse the repository at this point in the history
  • Loading branch information
xNatsuri authored Apr 27, 2024
2 parents 98397ab + 9c792ca commit 1969863
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 33 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/google/uuid v1.4.0
github.com/pelletier/go-toml v1.9.5
github.com/rogpeppe/go-internal v1.11.0
github.com/sandertv/gophertunnel v1.36.0
github.com/sandertv/gophertunnel v1.37.0
github.com/segmentio/fasthash v1.0.3
github.com/sirupsen/logrus v1.9.3
golang.org/x/exp v0.0.0-20230206171751-46f607a40771
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/sandertv/go-raknet v1.12.0 h1:olUzZlIJyX/pgj/mrsLCZYjKLNDsYiWdvQ4NIm3z0DA=
github.com/sandertv/go-raknet v1.12.0/go.mod h1:Gx+WgZBMQ0V2UoouGoJ8Wj6CDrMBQ4SB2F/ggpl5/+Y=
github.com/sandertv/gophertunnel v1.36.0 h1:VF2znM3FFUkPqOVnOeH0KgM5iI167AzSB2oqLxrn2F4=
github.com/sandertv/gophertunnel v1.36.0/go.mod h1:4El8ZfEpUmOMIJhPt5SCc1PyLNiuQ2+grWczrBvSGVs=
github.com/sandertv/gophertunnel v1.37.0 h1:yPzOp4W1GahLjtxldXa5K25saJK/XG7SiyEt6oMjm0I=
github.com/sandertv/gophertunnel v1.37.0/go.mod h1:4El8ZfEpUmOMIJhPt5SCc1PyLNiuQ2+grWczrBvSGVs=
github.com/segmentio/fasthash v1.0.3 h1:EI9+KE1EwvMLBWwjpRDc+fEM+prwxDYbslddQGtrmhM=
github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
Expand Down
14 changes: 2 additions & 12 deletions server/block/flower.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,12 @@ func (Flower) CompostChance() float64 {

// EncodeItem ...
func (f Flower) EncodeItem() (name string, meta int16) {
if f.Type == Dandelion() {
return "minecraft:yellow_flower", 0
} else if f.Type == WitherRose() {
return "minecraft:wither_rose", 0
}
return "minecraft:red_flower", int16(f.Type.Uint8() - 1)
return "minecraft:" + f.Type.String(), 0
}

// EncodeBlock ...
func (f Flower) EncodeBlock() (string, map[string]any) {
if f.Type == Dandelion() {
return "minecraft:yellow_flower", nil
} else if f.Type == WitherRose() {
return "minecraft:wither_rose", nil
}
return "minecraft:red_flower", map[string]any{"flower_type": f.Type.String()}
return "minecraft:" + f.Type.String(), nil
}

// allFlowers ...
Expand Down
16 changes: 8 additions & 8 deletions server/block/flower_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,25 +114,25 @@ func (f flower) Name() string {
func (f flower) String() string {
switch f {
case 0:
return "dandelion"
return "yellow_flower"
case 1:
return "poppy"
case 2:
return "orchid"
return "blue_orchid"
case 3:
return "allium"
case 4:
return "houstonia"
return "azure_bluet"
case 5:
return "tulip_red"
return "red_tulip"
case 6:
return "tulip_orange"
return "orange_tulip"
case 7:
return "tulip_white"
return "white_tulip"
case 8:
return "tulip_pink"
return "pink_tulip"
case 9:
return "oxeye"
return "oxeye_daisy"
case 10:
return "cornflower"
case 11:
Expand Down
5 changes: 4 additions & 1 deletion server/block/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/df-mc/dragonfly/server/item"
"github.com/df-mc/dragonfly/server/world"
"github.com/df-mc/dragonfly/server/world/particle"
"github.com/df-mc/dragonfly/server/world/sound"
"github.com/go-gl/mathgl/mgl64"
"image/color"
"strings"
Expand Down Expand Up @@ -119,9 +120,11 @@ func (s Sign) Wax(cube.Pos, mgl64.Vec3) (world.Block, bool) {
}

// Activate ...
func (s Sign) Activate(pos cube.Pos, _ cube.Face, _ *world.World, user item.User, _ *item.UseContext) bool {
func (s Sign) Activate(pos cube.Pos, _ cube.Face, w *world.World, user item.User, _ *item.UseContext) bool {
if editor, ok := user.(SignEditor); ok && !s.Waxed {
editor.OpenSign(pos, s.EditingFrontSide(pos, user.Position()))
} else if s.Waxed {
w.PlaySound(pos.Vec3(), sound.WaxedSignFailedInteraction{})
}
return true
}
Expand Down
Binary file modified server/item/creative/creative_items.nbt
Binary file not shown.
2 changes: 2 additions & 0 deletions server/item/honeycomb.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package item
import (
"github.com/df-mc/dragonfly/server/block/cube"
"github.com/df-mc/dragonfly/server/world"
"github.com/df-mc/dragonfly/server/world/sound"
"github.com/go-gl/mathgl/mgl64"
)

Expand All @@ -15,6 +16,7 @@ func (Honeycomb) UseOnBlock(pos cube.Pos, _ cube.Face, _ mgl64.Vec3, w *world.Wo
if wa, ok := w.Block(pos).(waxable); ok {
if res, ok := wa.Wax(pos, user.Position()); ok {
w.SetBlock(pos, res, nil)
w.PlaySound(pos.Vec3(), sound.SignWaxed{})
ctx.SubtractFromCount(1)
return true
}
Expand Down
Binary file modified server/item/recipe/crafting_data.nbt
Binary file not shown.
Binary file modified server/item/recipe/smithing_data.nbt
Binary file not shown.
Binary file removed server/item/recipe/stonecutter_data.nbt
Binary file not shown.
9 changes: 1 addition & 8 deletions server/item/recipe/vanilla.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ var (
vanillaCraftingData []byte
//go:embed smithing_data.nbt
vanillaSmithingData []byte
//go:embed stonecutter_data.nbt
vanillaStonecutterData []byte
)

// shapedRecipe is a recipe that must be crafted in a specific shape.
Expand Down Expand Up @@ -44,12 +42,7 @@ func init() {
panic(err)
}

var stonecutterRecipes []shapelessRecipe
if err := nbt.Unmarshal(vanillaStonecutterData, &stonecutterRecipes); err != nil {
panic(err)
}

for _, s := range append(craftingRecipes.Shapeless, stonecutterRecipes...) {
for _, s := range append(craftingRecipes.Shapeless) {

Check failure on line 45 in server/item/recipe/vanilla.go

View workflow job for this annotation

GitHub Actions / Build

x = append(y) is equivalent to x = y (SA4021)
input, ok := s.Input.Items()
output, okTwo := s.Output.Stacks()
if !ok || !okTwo {
Expand Down
2 changes: 1 addition & 1 deletion server/session/enchantment_texts.go

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

3 changes: 3 additions & 0 deletions server/session/handler_crafting.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ func matchingStacks(has, expected recipe.Item) bool {
switch expected := expected.(type) {
case item.Stack:
switch has := has.(type) {
case recipe.ItemTag:
name, _ := expected.Item().EncodeItem()
return has.Contains(name)
case item.Stack:
_, variants := expected.Value("variants")
if !variants {
Expand Down
7 changes: 7 additions & 0 deletions server/session/world.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,13 @@ func (s *Session) playSound(pos mgl64.Vec3, t world.Sound, disableRelative bool)
Position: vec64To32(pos),
})
return
case sound.SignWaxed:
s.writePacket(&packet.LevelEvent{
EventType: packet.LevelEventWaxOn,
Position: vec64To32(pos),
})
case sound.WaxedSignFailedInteraction:
pk.SoundType = packet.SoundEventWaxedSignInteractFail
case sound.Pop:
s.writePacket(&packet.LevelEvent{
EventType: packet.LevelEventSoundInfinityArrowPickup,
Expand Down
Binary file modified server/world/block_states.nbt
Binary file not shown.
Binary file modified server/world/item_runtime_ids.nbt
Binary file not shown.
1 change: 1 addition & 0 deletions server/world/mcdb/leveldat/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ type Data struct {
NaturalGeneration bool `nbt:"naturalgeneration"`
ProjectilesCanBreakBlocks bool `nbt:"projectilescanbreakblocks"`
ShowRecipeMessages bool `nbt:"showrecipemessages"`
IsHardcore bool `nbt:"IsHardcore"`
}

// FillDefault fills out d with all the default level.dat values.
Expand Down
6 changes: 6 additions & 0 deletions server/world/sound/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ type ComposterReady struct{ sound }
// LecternBookPlace is a sound played when a book is placed in a lectern.
type LecternBookPlace struct{ sound }

// SignWaxed is a sound played when a sign is waxed.
type SignWaxed struct{ sound }

// WaxedSignFailedInteraction is a sound played when a player tries to interact with a waxed sign.
type WaxedSignFailedInteraction struct{ sound }

// sound implements the world.Sound interface.
type sound struct{}

Expand Down

0 comments on commit 1969863

Please sign in to comment.