Skip to content

server/block: implement redstone-powered dispensers - #1345

Open
HashimTheArab wants to merge 8 commits into
df-mc:masterfrom
HashimTheArab:agent/dispenser-upstream
Open

server/block: implement redstone-powered dispensers#1345
HashimTheArab wants to merge 8 commits into
df-mc:masterfrom
HashimTheArab:agent/dispenser-upstream

Conversation

@HashimTheArab

Copy link
Copy Markdown
Collaborator

Summary

  • add the dispenser block, inventory, NBT, registration, container UI, and sounds
  • implement delayed redstone activation with Java-style quasi-connectivity and short-pulse handling
  • expose item.Dispensable and item.DispenseContext so vanilla and custom items own specialised dispenser behaviour without a central string registry
  • pass projectile ownership through *world.EntityHandle, with explicit nil support for ownerless dispenser launches
  • support ordinary item drops plus arrows, throwable projectiles, fireworks, buckets, TNT, flint and steel, bottles, honeycomb, and bone meal
  • complete hopper redstone locking against the current world-owned redstone engine

Why

Dragonfly did not have a registered dispenser implementation, and hoppers did not fully synchronize their locked state with accepted redstone power changes. This adds the missing vanilla container behavior while preserving the project policy of Java-style quasi-connectivity for dispensers. Item-specific actions live on their concrete item types, matching Dragonfly’s capability-interface style and allowing custom items to opt in.

Projectile factories now accept the persistent handle representation stored by their behaviours. This makes ownerless launches explicit at the type boundary and removes the forgettable entity-to-handle conversion helper.

Impact

Servers can place, persist, open, and power dispensers. Dispensers fire once per accepted rising edge after the vanilla four-tick delay, including short pulses, and launch supported projectiles without requiring an owning entity. Unsupported items are ejected normally; specialised items can explicitly report default, success, or failure outcomes. Hoppers now lock and unlock consistently with redstone power.

Ender pearls and attached fireworks reject nil owners; dispenser-compatible projectiles and unattached fireworks may remain ownerless. Bow, crossbow, and thrown-item paths pass the launching entity handle directly.

Validation

  • go test ./server/block
  • go test -race ./server/entity ./server/item ./server/block
  • go test ./...
  • go vet ./...
  • gofmt on all changed Go files
  • git diff --check
  • codex review --uncommitted (no actionable findings)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant