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 Crossbows #957

Merged
merged 52 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
5b67fbd
first attempt at crossbows
xNatsuri Dec 10, 2024
36b8c33
move crossbows to a chargeable interface.
xNatsuri Dec 13, 2024
727cb71
remove redundant return and other release change
xNatsuri Dec 13, 2024
df4c44c
revert main.go changes
xNatsuri Dec 13, 2024
203d970
Merge branch 'df-mc:master' into crossbow
xNatsuri Dec 14, 2024
25932db
Merge branch 'master' of https://github.com/xNatsuri/dragonfly into c…
xNatsuri Dec 14, 2024
4fb2a99
Merge branch 'df-mc:master' into crossbow
xNatsuri Dec 15, 2024
bc196c3
Merge branch 'crossbow' of https://github.com/xNatsuri/dragonfly into…
xNatsuri Dec 15, 2024
19569d7
requested changes
xNatsuri Dec 15, 2024
91eb288
remove unused interface and rename Release method
xNatsuri Dec 15, 2024
534d257
Merge branch 'df-mc:master' into crossbow
xNatsuri Dec 15, 2024
8cae7d8
use rotation.Neg() for arrows
xNatsuri Dec 15, 2024
0633645
fix rot
xNatsuri Dec 16, 2024
f801edd
Merge branch 'df-mc:master' into crossbow
xNatsuri Dec 20, 2024
bbd3c19
fix item charge and releasing issue
xNatsuri Dec 21, 2024
2a26e69
changes
xNatsuri Dec 21, 2024
5b51804
add quick charge sounds
xNatsuri Dec 22, 2024
6d784ec
Merge branch 'df-mc:master' into crossbow
xNatsuri Dec 22, 2024
bcd9f5f
requested changes
xNatsuri Dec 22, 2024
af49dae
Merge remote-tracking branch 'origin/crossbow' into crossbow
xNatsuri Dec 22, 2024
135f6a7
changes
xNatsuri Dec 22, 2024
c89071c
change name
xNatsuri Dec 22, 2024
6a2a1d3
move to internal package
xNatsuri Dec 22, 2024
0abdcce
account for offHand
xNatsuri Dec 22, 2024
9e35521
better match vanilla velocity
xNatsuri Dec 22, 2024
d044460
Merge branch 'df-mc:master' into crossbow
xNatsuri Dec 23, 2024
ff324a3
Merge branch 'df-mc:master' into crossbow
xNatsuri Dec 24, 2024
daf4a39
allow bow to use offhand arrows
xNatsuri Dec 24, 2024
9bc9204
rename NewItem func to DuplicateStack and use in handleCraftHandler
xNatsuri Dec 24, 2024
0552bab
reverse main changes
xNatsuri Dec 24, 2024
399205a
changes
xNatsuri Dec 24, 2024
d427bff
Merge branch 'df-mc:master' into crossbow
xNatsuri Dec 24, 2024
a701deb
fix
xNatsuri Dec 24, 2024
662f8e8
Merge branch 'df-mc:master' into crossbow
xNatsuri Dec 24, 2024
ccdca06
Merge branch 'crossbow' of https://github.com/xNatsuri/dragonfly into…
xNatsuri Dec 24, 2024
1bde76d
use WithItem
xNatsuri Dec 24, 2024
db7cbe3
Merge branch 'df-mc:master' into crossbow
xNatsuri Dec 24, 2024
e70b3af
changes
xNatsuri Dec 25, 2024
9693ec3
changes
xNatsuri Dec 25, 2024
d1fc7a7
fix
xNatsuri Dec 25, 2024
212cd1f
Merge branch 'df-mc:master' into crossbow
xNatsuri Dec 28, 2024
0639438
Merge branch 'master' into crossbow
DaPigGuy Dec 29, 2024
836f5ec
fixup!
DaPigGuy Dec 29, 2024
f8488c6
Merge branch 'df-mc:master' into crossbow
xNatsuri Jan 2, 2025
7516809
fix
xNatsuri Jan 3, 2025
60f5b35
Merge remote-tracking branch 'origin/crossbow' into crossbow
xNatsuri Jan 3, 2025
cdf6253
revert main.go
xNatsuri Jan 3, 2025
af28e0e
Add middle loading sound and (maybe) fix funky loading
RoyalMCPE Jan 3, 2025
462a40d
cleanup
RoyalMCPE Jan 3, 2025
9148ace
Merge pull request #1 from RoyalMCPE/crossbow
xNatsuri Jan 3, 2025
bec2619
Merge branch 'df-mc:master' into crossbow
xNatsuri Jan 4, 2025
1f2b43d
changes
xNatsuri Jan 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions server/item/bow.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package item

import (
"github.com/df-mc/dragonfly/server/block/cube"
"github.com/df-mc/dragonfly/server/item/potion"
"github.com/df-mc/dragonfly/server/world"
"github.com/df-mc/dragonfly/server/world/sound"
Expand Down Expand Up @@ -55,11 +54,6 @@ func (Bow) Release(releaser Releaser, tx *world.Tx, ctx *UseContext, duration ti
return
}

rot := releaser.Rotation()
rot = cube.Rotation{-rot[0], -rot[1]}
if rot[0] > 180 {
rot[0] = 360 - rot[0]
}
var tip potion.Potion
if !arrow.Empty() {
// Arrow is empty if not found in the creative inventory.
Expand All @@ -84,7 +78,7 @@ func (Bow) Release(releaser Releaser, tx *world.Tx, ctx *UseContext, duration ti
}

create := tx.World().EntityRegistry().Config().Arrow
opts := world.EntitySpawnOpts{Position: eyePosition(releaser), Velocity: releaser.Rotation().Vec3().Mul(force * 5), Rotation: rot}
opts := world.EntitySpawnOpts{Position: eyePosition(releaser), Velocity: releaser.Rotation().Vec3().Mul(force * 5), Rotation: releaser.Rotation().Neg()}
projectile := tx.AddEntity(create(opts, damage, releaser, force >= 1, false, !creative && consume, punchLevel, tip))
if f, ok := projectile.(interface{ SetOnFire(duration time.Duration) }); ok {
f.SetOnFire(burnDuration)
Expand Down
11 changes: 2 additions & 9 deletions server/item/crossbow.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package item

import (
"github.com/df-mc/dragonfly/server/block/cube"
"github.com/df-mc/dragonfly/server/item/potion"
"github.com/df-mc/dragonfly/server/world"
"time"
Expand Down Expand Up @@ -72,28 +71,22 @@ func (c Crossbow) ReleaseCharge(releaser Releaser, tx *world.Tx, ctx *UseContext

creative := releaser.GameMode().CreativeInventory()

rot := releaser.Rotation()
rot = cube.Rotation{-rot[0], -rot[1]}
if rot[0] > 180 {
rot[0] = 360 - rot[0]
}

dirVec := releaser.Rotation().Vec3().Normalize()

if firework, isFirework := c.Item.Item().(Firework); isFirework {
createFirework := tx.World().EntityRegistry().Config().Firework
xNatsuri marked this conversation as resolved.
Show resolved Hide resolved
fireworkEntity := createFirework(world.EntitySpawnOpts{
Position: torsoPosition(releaser),
Velocity: dirVec.Mul(1.5),
Rotation: rot,
Rotation: releaser.Rotation().Opposite(),
xNatsuri marked this conversation as resolved.
Show resolved Hide resolved
}, firework, releaser, false)
tx.AddEntity(fireworkEntity)
} else {
createArrow := tx.World().EntityRegistry().Config().Arrow
arrow := createArrow(world.EntitySpawnOpts{
Position: torsoPosition(releaser),
Velocity: dirVec.Mul(3.0),
Rotation: rot,
Rotation: releaser.Rotation().Neg(),
}, 9, releaser, true, false, !creative, 0, potion.Potion{})
xNatsuri marked this conversation as resolved.
Show resolved Hide resolved
tx.AddEntity(arrow)
}
Expand Down
Loading