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

Implemented shields #643

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Implemented shields #643

wants to merge 11 commits into from

Conversation

JustTalDevelops
Copy link
Member

@JustTalDevelops JustTalDevelops commented Aug 16, 2022

No description provided.

server/player/player.go Outdated Show resolved Hide resolved
@JustTalDevelops JustTalDevelops marked this pull request as ready for review August 16, 2022 18:23
@JustTalDevelops JustTalDevelops added the feature New feature or request label Aug 16, 2022
@JustTalDevelops JustTalDevelops marked this pull request as draft August 17, 2022 05:41
@JustTalDevelops JustTalDevelops marked this pull request as ready for review August 17, 2022 17:23
@@ -191,6 +191,11 @@ func (a *Arrow) Rotation() (float64, float64) {
return a.yaw, a.pitch
}

// blocker represents an entity that can block attacks with a shield.
type blocker interface {
Blocking() (bool, bool)
Copy link
Member

Choose a reason for hiding this comment

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

I would document this method and probably add named return types here, because it's unclear what this should return.

Copy link
Contributor

Choose a reason for hiding this comment

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

note: resolved

Comment on lines 552 to 587
if ok, _ := p.Blocking(); ok && source.ReducedByArmour() {
affected := true
if src, ok := source.(damage.SourceEntityAttack); ok {
diff := p.Position().Sub(src.Attacker.Position())
diff[1] = 0
if diff.Dot(entity.DirectionVector(p)) >= 0.0 {
affected = false
}
}
if affected {
w.PlaySound(pos, sound.ShieldBlock{})
p.SetBlockingDelay(time.Millisecond * 250)

if src, ok := source.(damage.SourceEntityAttack); ok {
if l, ok := src.Attacker.(entity.Living); ok {
l.KnockBack(pos, 0.5, 0.4)
}
if a, ok := src.Attacker.(*Player); ok {
held, _ := a.HeldItems()
if _, ok := held.Item().(item.Axe); ok {
p.SetBlockingDelay(time.Second * 5)
}
}
}
if dmg >= 3.0 {
i := int(math.Ceil(totalDamage))
held, other := p.HeldItems()
if _, ok := held.Item().(item.Shield); ok {
p.SetHeldItems(p.damageItem(held, i), other)
} else {
p.SetHeldItems(held, p.damageItem(other, i))
}
}
return 0, false
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Could you pull this out in its own method and add some documentation (if and where relevant)? This is a massive block of code and Player.Hurt() is already a pretty big function as it is.

Copy link
Contributor

Choose a reason for hiding this comment

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

any method name suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

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

this has been resolved, once the conflicts are resolved, are we ready to merge?

server/player/player.go Outdated Show resolved Hide resolved
server/player/player.go Outdated Show resolved Hide resolved
# Conflicts:
#    server/entity/arrow.go
#    server/player/player.go
#    server/session/entity_metadata.go
@lightyisreal
Copy link
Contributor

Anything about this?

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.

7 participants