Skip to content

Commit

Permalink
use WithItem
Browse files Browse the repository at this point in the history
  • Loading branch information
xNatsuri committed Dec 24, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent ccdca06 commit 1bde76d
Showing 3 changed files with 2 additions and 33 deletions.
20 changes: 0 additions & 20 deletions server/internal/iteminternal/stack_transfer.go

This file was deleted.

9 changes: 2 additions & 7 deletions server/item/crossbow.go
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ func (c Crossbow) Charge(releaser Releaser, tx *world.Tx, ctx *UseContext, durat
ctx.Consume(c.Item)
}

crossbow := duplicateStack(held, c)
crossbow := held.WithItem(c)
releaser.SetHeldItems(crossbow, left)
return true
}
@@ -100,7 +100,7 @@ func (c Crossbow) ReleaseCharge(releaser Releaser, tx *world.Tx, ctx *UseContext

c.Item = Stack{}
held, left := releaser.HeldItems()
crossbow := duplicateStack(held, c)
crossbow := held.WithItem(c)
releaser.SetHeldItems(crossbow, left)
tx.PlaySound(releaser.Position(), sound.CrossbowShoot{})
return true
@@ -150,11 +150,6 @@ func (c Crossbow) EncodeNBT() map[string]any {
return nil
}

// noinspection ALL
//
//go:linkname duplicateStack github.com/df-mc/dragonfly/server/internal/iteminternal.DuplicateStack
func duplicateStack(stack Stack, item world.Item) Stack

// noinspection ALL
//
//go:linkname writeItem github.com/df-mc/dragonfly/server/internal/nbtconv.WriteItem
6 changes: 0 additions & 6 deletions server/session/handler_crafting.go
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ import (
"github.com/sandertv/gophertunnel/minecraft/protocol"
"math"
"slices"
_ "unsafe"
)

// handleCraft handles the CraftRecipe request action.
@@ -225,8 +224,3 @@ func grow(i recipe.Item, count int) recipe.Item {
}
panic(fmt.Errorf("unexpected recipe item %T", i))
}

// noinspection ALL
//
//go:linkname duplicateStack github.com/df-mc/dragonfly/server/internal/iteminternal.DuplicateStack
func duplicateStack(stack item.Stack, item world.Item) item.Stack

0 comments on commit 1bde76d

Please sign in to comment.