Skip to content

Dev: ship stats#25

Open
def9a2a4 wants to merge 14 commits into
mainfrom
dev-stats
Open

Dev: ship stats#25
def9a2a4 wants to merge 14 commits into
mainfrom
dev-stats

Conversation

@def9a2a4
Copy link
Copy Markdown
Owner

see #18

def9a2a4 added 14 commits May 11, 2026 21:23
…d/rotation scaling

Ships now derive their speed, acceleration, and rotation from a power-to-mass
ratio based on sail composition. Wool blocks (3 pts) and banners (7 pts)
provide sail power; every ship gets 2 free base points. The ratio linearly
interpolates between absolute floors (1 block/sec speed, 30s/revolution
rotation) and caps (1.5x default stats), with ratio 0.7 mapping to current
defaults. Sails cap at ratio 0.8 — engines (not yet implemented) will be
needed to push past it.

Airship vertical speed scales with density magnitude rather than the
horizontal ratio.

Also adds ship_engine custom item definition (8 copper + blast furnace recipe)
and updates the ship info display to show wool/banner counts, power ratio, and
effective speed percentage.
Engine system: tagged blast furnace crafted from 8 copper + blast furnace.
BlockPlaceEvent listener transfers PDC tag to TileState, vanilla smelting
suppressed on engine blocks. Scanner and detection count engines via PDC
check. Engine power (30 pts/engine) wired into the ratio calculation for
both horizontal and airship vertical stats. Ship info display and detection
chat messages now show engine count and engine-adjusted power ratio.

Also extracts hardcoded help book content from ShipWheelMenu into
HelpBookContent.java + help_book.yml, loaded once at plugin startup.
Adds the full engine fuel system on top of the engine detection foundation.
Engines now require fuel to contribute power to the ship's ratio. Includes:

- EngineMenuGUI: 3 fuel slots per engine, opened by right-clicking the
  engine block on an assembled ship. Validates fuel-only items, saves on close.
- Fuel consumption: burns 1 tick per game tick while W held. Auto-consumes
  next fuel item when current burns out. Recomputes effective stats on change.
- Smoke particles: CAMPFIRE_SIGNAL_SMOKE at fueled engine positions every
  5 ticks while ship has a driver.
- Fuel state persistence: per-engine fuel slots and burn ticks serialized
  to ship_wheels.yml via Base64-encoded ItemStack bytes.
- Engine block indices and local positions tracked in ShipModel for click
  detection and particle spawning.
- ShipInstance now holds a wheelData reference (set during assembly) for
  fuel state access in the physics loop.

Note: DisplayShip.java and config.yml include unrelated changes from a
concurrent Captain's Manual fix branch (shapeless recipes, help lore).
- Reload help book content on /blockships reload
- Support shapeless recipes in ItemUtil.registerItemRecipe()
- Replace verbose help lore (full book dump) with terse controls summary
- Remove unused getHelpSections() from ShipWheelMenu
- Fix speed percentage display: divide by sail cap (0.8) not default (0.7)
  so 100% means "max sails" rather than "default speed"
- Bump floor-acceleration from 0.005 to 0.015 (less sluggish minimum)
…ne glint

- Simplify ship info book hover to show only speed % (detailed breakdown
  moved to a new Ship Stats banner item at slot 20)
- Speed % now uses sail cap (0.8) as 100% baseline instead of default
  ratio (0.7) — over 100% means engines are contributing
- Stats banner shows wool/banner/engine counts, sail power with "capped
  at 80%" indicator when applicable, mass, power ratio, and speed %
- Add config-driven enchantment glint support to CustomItem (enchant-glint
  field); ship_engine gets glint by default
- Fix floor acceleration default mismatch (config says 0.015, code
  fallback said 0.005)
Previously only ship_wheel and ship kits were giveable. Now supports:
- captains_manual (written help book)
- any custom-items entry (ship_engine, balloon, etc.)

Also adds tab completion for all giveable items and extracts
item listing into shared helpers to avoid duplication.
New config keys added in plugin updates (like ship_engine, stats section)
were invisible to existing servers because Bukkit's saveDefaultConfig()
never overwrites an existing config.yml. Users had to manually delete
their config to get new entries.

migrateConfig() now runs at startup: loads the jar's bundled config,
walks all leaf keys, and adds any that are missing from the user's
config. Never overwrites existing values — customizations are preserved.
Controlled by `auto-migrate-config: true` (opt-out by setting false).
Speed % now color-coded: red (<50%), gold (50-74%), yellow (75-99%),
green (100-124%), aqua (125%+). Ships below 50% speed show a hint to
add sails. Density line now combines the numeric value with a colored
float status label (e.g., "1.33 (Floats well)") instead of separate
lines. Removed surface offset from hover (redundant).

Applied consistently across ship info hover, stats banner, and
detection chat messages.
…er ref

- Engine blocks now drop the custom ship engine item (with PDC + glint)
  instead of a vanilla blast furnace when broken
- Add totalPositiveWeight field to ShipModel so assembled ships report
  correct positive weight instead of passing clamped maxHealth
- Guard computeStat() against divide-by-zero when defaultRatio >= 1.0
- Use local plugin reference for engine PDC check in scanner instead of
  redundant global lookup
Rename totalPositiveWeight → mass (sum of max(0, weight) per block).
This is the correct denominator for the power-to-mass ratio: it
represents how much solid material sails need to push, excluding
negative-weight floatation blocks.

Fixes airships getting zero sail benefit — getSailRatio() previously
returned 0 for negative totalWeight. Now uses mass, so airships with
sails correctly get horizontal speed benefit.

Also fixes:
- engineBlockIndices changed from Set to List so iteration order
  matches engineLocalPositions (fixes smoke at wrong engine / IOOBE)
- Lazy resolveWheelData() for chunk-recovered ships — looks up via
  ShipWheelManager.getWheelByShipUUID() on first access so fuel state
  is correctly loaded instead of assuming all engines fueled
- Shift-click non-fuel into engine GUI now blocked
- Dried kelp burn time 4001 → 4000
- YAML key renamed to "mass" with backwards-compat read of old
  "total_positive_weight" key
…er ref

Engine PDC preserved on disassembly (is_engine flag in rawYaml, restored
in placeBlocks). Ship info uses countFueledEngines() for ratio and shows
fueled/unfueled engines separately. Smoke particles now spawn at engine
shulker position instead of manual coordinate transform. Placed (unassembled)
engine blocks open the custom fuel GUI instead of vanilla furnace UI.
Shift-click non-fuel into engine GUI blocked. Smoke changed to
CAMPFIRE_COSY_SMOKE for shorter duration.

Known issues still unfixed:
- countFueledEngines() doesn't know total engine set (uses computeIfAbsent
  side effect, phantom map entries); needs engine indices parameter
- getShipInfo() uses stale lastDetected* fields for assembled ships instead
  of live ShipInstance data — mass can be 0/stale, effective power = mass
- Engine fuel state and detection data are disconnected systems
- Chat detection messages don't match lore format (missing mass, ratio)
- Unassembled ships show engines at full potential points, not as unfueled
…back

Root cause: assembleShip() never called setLastHealth() or
setLastDetectedStats(), so the ship wheel menu fell into the
"unassembled" display branch (lastMaxHealth=0) even for assembled
ships. This showed all engines at full potential points instead of
the fueled/unfueled breakdown.

Fixes:
- Set lastHealth + detection stats during assembly so menu has
  correct data immediately
- getShipInfo() now reads live ShipInstance data (model + fuel state)
  for assembled ships instead of stale lastDetected* fields
- countFueledEngines() takes engine block indices list so it checks
  ALL engines, not just those with map entries
- getEngineFuelSlots() no longer uses computeIfAbsent (was creating
  phantom entries in the fuel map)
- Physics fallback changed from engineCount (all fueled) to 0
  when wheelData is null
- tickEngineFuel skips engines with no fuel map entry
- Engine display always shows fueled/unfueled breakdown regardless
  of assembled state
- Engine GUI status shows Running/Ready/Idle based on burn ticks
  AND fuel items in slots
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