Skip to content

Commit

Permalink
Merge branch 'df-mc:master' into crossbow
Browse files Browse the repository at this point in the history
  • Loading branch information
xNatsuri authored Jan 4, 2025
2 parents 9148ace + 0347c6e commit bec2619
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 30 deletions.
24 changes: 9 additions & 15 deletions server/block/explosion.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,9 @@ func (c ExplosionConfig) Explode(tx *world.Tx, explosionPos mgl64.Vec3) {
tx.SetBlock(pairPos, pair, nil)
}
}

for _, i := range cb.Inventory(tx, pos).Clear() {
dropItem(tx, i, pos.Vec3())
}
} else {
for _, i := range container.Inventory(tx, pos).Clear() {
dropItem(tx, i, pos.Vec3())
}
}
for _, i := range container.Inventory(tx, pos).Clear() {
dropItem(tx, i, pos.Vec3())
}
}
}
Expand Down Expand Up @@ -195,7 +190,7 @@ func exposure(tx *world.Tx, origin mgl64.Vec3, e world.Entity) float64 {
xOffset := (1.0 - math.Floor(diff[0])/diff[0]) / 2.0
zOffset := (1.0 - math.Floor(diff[2])/diff[2]) / 2.0

var checks, misses int
var checks, misses float64
for x := 0.0; x <= 1.0; x += step[0] {
for y := 0.0; y <= 1.0; y += step[1] {
for z := 0.0; z <= 1.0; z += step[2] {
Expand All @@ -204,21 +199,20 @@ func exposure(tx *world.Tx, origin mgl64.Vec3, e world.Entity) float64 {
lerp(y, boxMin[1], boxMax[1]),
lerp(z, boxMin[2], boxMax[2]) + zOffset,
}

var collided bool
trace.TraverseBlocks(origin, point, func(pos cube.Pos) (con bool) {
_, air := tx.Block(pos).(Air)
collided = !air
return air
trace.TraverseBlocks(origin, point, func(pos cube.Pos) (cont bool) {
_, collided = trace.BlockIntercept(pos, tx, tx.Block(pos), origin, point)
return !collided
})

if !collided {
misses++
}
checks++
}
}
}
return float64(misses) / float64(checks)
return misses / checks
}

// lerp returns the linear interpolation between a and b at t.
Expand Down
2 changes: 1 addition & 1 deletion server/block/note.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (n Note) Activate(pos cube.Pos, _ cube.Face, tx *world.Tx, _ item.User, _ *

// BreakInfo ...
func (n Note) BreakInfo() BreakInfo {
return newBreakInfo(0.8, alwaysHarvestable, axeEffective, oneOf(n))
return newBreakInfo(0.8, alwaysHarvestable, axeEffective, oneOf(Note{}))
}

// FuelInfo ...
Expand Down
7 changes: 3 additions & 4 deletions server/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,17 +372,16 @@ func (s *Session) background() {
// sendChunks sends the next up to 4 chunks to the connection. What chunks are loaded depends on the connection of
// the chunk loader and the chunks that were previously loaded.
func (s *Session) sendChunks(tx *world.Tx, c Controllable) {
if w := tx.World(); s.chunkLoader.World() != w && w != nil {
s.handleWorldSwitch(w, tx, c)
}
pos := c.Position()
s.chunkLoader.Move(tx, pos)
s.writePacket(&packet.NetworkChunkPublisherUpdate{
Position: protocol.BlockPos{int32(pos[0]), int32(pos[1]), int32(pos[2])},
Radius: uint32(s.chunkRadius) << 4,
})

if w := tx.World(); s.chunkLoader.World() != w && w != nil {
s.handleWorldSwitch(w, tx, c)
}

s.blobMu.Lock()
const maxChunkTransactions = 8
toLoad := maxChunkTransactions - len(s.openChunkTransactions)
Expand Down
17 changes: 7 additions & 10 deletions server/world/world.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@ import (
"encoding/binary"
"errors"
"fmt"
"iter"
"maps"
"math/rand/v2"
"sync"
"time"

"github.com/df-mc/goleveldb/leveldb"

"slices"

"github.com/df-mc/dragonfly/server/block/cube"
"github.com/df-mc/dragonfly/server/event"
"github.com/df-mc/dragonfly/server/internal/sliceutil"
"github.com/df-mc/dragonfly/server/world/chunk"
"github.com/df-mc/goleveldb/leveldb"
"github.com/go-gl/mathgl/mgl64"
"github.com/google/uuid"
"iter"
"maps"
"math/rand/v2"
"slices"
"sync"
"sync/atomic"
"time"
)

// World implements a Minecraft world. It manages all aspects of what players
Expand Down

0 comments on commit bec2619

Please sign in to comment.