Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement curse of binding #716

Closed
wants to merge 16 commits into from
Closed

Implement curse of binding #716

wants to merge 16 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Dec 21, 2022

No description provided.

server/item/enchantment/curse_of_binding.go Outdated Show resolved Hide resolved
server/session/handler_item_stack_request.go Outdated Show resolved Hide resolved
server/session/handler_item_stack_request.go Outdated Show resolved Hide resolved
server/session/handler_item_stack_request.go Outdated Show resolved Hide resolved
server/session/handler_item_stack_request.go Outdated Show resolved Hide resolved
server/session/handler_item_stack_request.go Outdated Show resolved Hide resolved
server/session/handler_item_stack_request.go Outdated Show resolved Hide resolved
@ghost ghost requested review from DaPigGuy and removed request for JustTalDevelops December 22, 2022 20:36
Copy link
Member

@DaPigGuy DaPigGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be a good idea to move the Curse of Binding logic to its own function, since it's duplicated several times in this handler, something like:

func (h *ItemStackRequestHandler) validateCurse(slot protocol.StackRequestSlotInfo, s *Session) error {
}
if err := validateCurse(a.Source, s); err != nil {
    return err
}

You could also change that function to return a bool rather than an error if you want more descriptive errors (swap vs. transfer vs. drop).

Co-authored-by: DaPigGuy <mcpepig123@gmail.com>
@DaPigGuy
Copy link
Member

DaPigGuy commented Jan 9, 2023

@Sandertv Can we try and get this merged soon?

@@ -2930,6 +2930,11 @@ func (p *Player) useContext() *item.UseContext {
srcIt, _ := srcInv.Item(src)
dstIt, _ := dstInv.Item(dst)

// If dstIt is enchanted with curse of binding, do not swap.
if _, isCursed := dstIt.Enchantment(enchantment.CurseOfBinding{}); isCursed && !p.GameMode().CreativeInventory() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels out of place. How could this ever happen? I assume any attempt to move the item out will be cancelled at the session level?

Copy link
Author

@ghost ghost Jan 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not get cancelled at the session level.

Alternatively, I could modify relevant items' Use() function and check if the carrier (player) is wearing armour enchanted with curse of binding.

@JustTalDevelops JustTalDevelops added the feature New feature or request label Jan 15, 2023
@ghost ghost closed this by deleting the head repository Mar 21, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants