Commit graph

190 commits

Author SHA1 Message Date
Lazzexus
e1e59fe66c Draw belts, underground belts and splitters with their direction
Belts are drawn like the in-game map: a strip in the colour of their tier
(taken from the icon of the transport belt of the same tier), with an arrow
per lane in the direction items go. Splitters are drawn at their rotated
2x1 footprint with a bar across the back.

The mod now sends whether an underground belt is an entrance or an exit.
Entrances are capped on the side where items go underground, exits on the
side where they come out, and the hover tooltip says which it is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 10:21:11 +01:00
Lazzexus
9d1f9b7623 Show building rotation, recipes and other surfaces on the web map
The mod now sends each building's direction and recipe (furnaces: the last
recipe, since they only have one while working).
- Rotated buildings are drawn at their real footprint.
- Crafting machines show their recipe icon, like Factorio's alt mode, and
  the hover tooltip includes the recipe.

The web map has a surface drop-down (e.g. Space Exploration planets and
orbits), backed by a new surfaces endpoint. Every layer, the resource labels
and the player markers follow the chosen surface.

Resource labels use the in-game names (e.g. "Iridite" instead of
"Se iridium ore"). export_building_icons.py also exports recipe icons, plus
recipe and resource names.

The three in-memory views in events-server-web now share one helper for
following a Kafka topic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 10:14:39 +02:00
Lazzexus
4aba8d67f3 Detect infinite resources by minimum yield, not infinite_resource
On Factorio 2.0 (with Space Exploration + Krastorio 2), crude oil and
mineral water report infinite_resource=false and a nil initial_amount,
but only infinite resources have a minimum_resource_amount > 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 07:46:23 +02:00
Lazzexus
3d8673fe03 Add resource patch labels to the web map
Group nearby resource tiles of the same type into patches, and label
them on the map, e.g. "Iron ore / 2.4M", or "Crude oil / 12 wells".

- events-library: ResourcePatch model, shared by the server and map.
- events-server-web: ResourcePatchService reads the map-chunk-resource
  topic from the beginning (read_committed) into memory, and on request
  groups tiles into connected patches (join distance 2 tiles for ore,
  12 for infinite resources, whose wells are spread out). Results are
  cached until new data arrives.
  New endpoint: GET .../servers/{id}/map/resources/s{surface}/patches
- web-map: toggleable "Resource patches" overlay with labels at each
  patch centre and a hover tooltip, refreshed every minute. Patches
  under 10 tiles are hidden. (Surface 1 only, like the rest of the map.)
- events-mod: mark resources infinite based on the prototype's
  infinite_resource. Entity initial_amount is nil for e.g. crude oil, so
  oil fields were treated as hundreds of tiny ore patches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 07:07:23 +02:00
Lazzexus
d680608deb Send resources and existing buildings when re-sending chunks
'/kafkatorio chunks' only re-sent chunk terrain: resources were only
sent when Factorio first generated a chunk, and buildings only when
built or mined. A save that predates the mod therefore showed no
resources or buildings at all.

Re-sent chunks now also go through the entity chunk handler, which now
also includes the chunk's existing player-force buildings (excluding
characters). Newly generated chunks contain no buildings, so that path
is unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 20:04:50 +02:00
Lazzexus
a31e392742 Fix '/kafkatorio chunks' not sending most chunks
- EventDataQueue.enqueue: `key ! in storage.store` parses as a non-null
  assertion followed by `in`, so the check was inverted: a key was only
  queued if it was already in the store. A first enqueue stored the
  event but never queued it, so it was never sent.
- The chunks command keyed the queue with `${surface}${x}${y}`, so
  different chunks collided (e.g. surface 1, (1,12) and (11,2) both
  became "1112"). Separate the parts with '_'.

Saves that ran the broken version keep orphaned queue entries; run
`/kafkatorio init_global` once to clear them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 18:16:20 +02:00
Lazzexus
ab342caf4d Filter resource entities by prototype type, not collision layer
Caught by another in-game crash: "Entity is not resource." when
reading entity.amount. The previous fix (collision_mask: "resource")
was still wrong - collision layers and entity type are decoupled in
Factorio 2.0, so find_entities_filtered({collision_mask: "resource"})
can return non-resource entities that merely opted into the same
collision layer (likely something from Space Exploration or
Krastorio 2). entity.amount/initial_amount only exist on entities
whose prototype type is actually "resource".

Filtering by type: "resource" directly targets the right entities
and is simpler than inferring it via collision mask in the first
place.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-12 16:36:12 +02:00
Lazzexus
cbb0b6e853 Fix collision layer name: "resource-layer" -> "resource" (Factorio 2.0)
Caught by an in-game crash on real Factorio 2.0.77 (with Space
Exploration + Krastorio 2 loaded):

  Error while running event kafkatorio-events::on_chunk_generated
  Unknown collision-layer name: resource-layer

Factorio 2.0 made collision layers fully prototype-defined (previously
a fixed set of built-in names). Checked the official factorio-data
2.0.77 tag's core/lualib/collision-mask-defaults.lua: resource-type
entities now use layer name "resource", not "resource-layer". Fixed
both find_entities_filtered() call sites in EntityUpdateHandler.ts
that scan for resource entities around mined/placed tiles and newly
generated chunks.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-12 16:32:57 +02:00
Lazzexus
cbe0f35fdd Fix invalid mod-setting prototype name (colon not allowed)
Caught by actually running the mod on a real Factorio 2.0.77 server:

  Error while loading mod-setting prototype
  "kafkatorio:cache-expiration-seconds_kafkatorio-packet-keyed-PlayerUpdate"
  (double-setting): Invalid prototype name. Only characters
  A-Z a-z 0-9 _- are allowed.

cacheDurationSettingName() built names with a ":" separator
("kafkatorio:cache-expiration-seconds_..."), which Factorio 2.0
rejects outright. Replaced it with "-", matching the mod-name-prefix
convention the engine's own docs recommend. This is a pure runtime
validation issue invisible to the TypeScript compiler - exactly the
kind of thing only actually loading the mod in-game catches.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-12 16:12:39 +02:00
Lazzexus
ac8855c679 Fix changelog version number to match the actual project version
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-12 15:53:50 +02:00
Lazzexus
5621dbcd82 Fix mod zip layout: set tsconfig rootDir so control.lua lands at mod root
Without an explicit rootDir, tstl computed output paths relative to
tsconfig.json's own directory (modules/events-mod/) rather than the
actual TypeScript source root (src/main/typescript/), so control.lua
and settings.lua ended up nested under src/main/typescript/ in the
packaged mod zip instead of at its root - where Factorio requires them
to be. The mod would not have loaded at all as packaged.

This went uncaught because packageFactorioMod never previously
produced real output (blocked by the now-fixed kxs-ts-gen-core/JitPack
issue). Verified by actually running packageFactorioMod and inspecting
the resulting zip: control.lua, settings.lua and info.json are now at
the root, and control.lua's require() calls ("main.global-init" etc.)
correctly resolve against that flat layout.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-12 15:53:03 +02:00
Lazzexus
6ea10ae910 Fix kxs-ts-gen-core dependency resolution and unblocked compile bugs
The version catalog pointed kxs-ts-gen-core at a JitPack coordinate
(com.github.adamko-dev.kotlinx-serialization-typescript-generator) that
no longer serves real artifacts there, despite JitPack's build-status
API still reporting it as built. The library is properly published to
Maven Central under dev.adamko.kxstsgen - a commented-out line with
that exact coordinate was already sitting in the catalog. Swapping to
it fixes dependency resolution for every module depending on
versions-platform (which previously blocked any Gradle task touching
events-library, including all of its tests).

That unblocked two more pre-existing, unrelated bugs that had never
been caught because this module never previously compiled:

- LuaJsonList<T> : List<T> by list triggered a longstanding Kotlin
  compiler bug (KT-3546, "accidental override" on generic toArray)
  specific to delegating java.util.List via `by`. Replaced with a
  hand-written Collection<T> implementation (no delegation codegen,
  no bug), which still satisfies Kotest's forOne/forAll inspectors -
  the only thing any code actually needs from it.
- The kxs-ts-gen Kotlin->TypeScript generator (kt2ts2.kt) still emitted
  the pre-2.0 bare `uint`/`int` names and no import statement, since it
  predates typed-factorio's move to virtual modules. Updated its
  primitive-type mappings to uint32/int32 and added the "factorio:runtime"
  import to its generated header, so the regenerated schema matches what
  the rest of events-mod now expects.

Verified via real Gradle tasks (not just manual tooling): events-library
compiles and all tests pass; events-mod's full build - Kotlin schema
generation, npm install, tstl compile, and info.json generation (with
factorio_version "2.0" and the space-exploration/Krastorio2 optional
dependencies) - succeeds end-to-end.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-12 15:40:33 +02:00
Lazzexus
beb0d7c430 Fix compile errors surfaced by actually building against Factorio 2.0.77
typed-factorio 2.0.0+ stopped declaring types as ambient globals - they
now live in virtual modules ("factorio:runtime", "factorio:common",
"factorio:settings") and must be explicitly imported. Adds those imports
throughout events-mod. Also:

- Bumps typescript-to-lua 1.11.1 -> 1.25.2 and typescript 4.9 -> 5.4.2,
  since tstl pins an exact peer TypeScript version and typed-factorio
  3.x needs a newer one than 4.9 supports (a real compiler bug in
  TS 4.9 against the generated defines.segmented_unit_ai_state enum).
- Bumps the pinned isolated Node (14.19.1 -> 24.21.0), since
  typescript-to-lua 1.25.2 requires Node >=16.10.0.
- Renames bare uint/int -> uint32/int32 (import aliases), since the
  unsized aliases no longer exist.
- Drops OnEntityDestroyedEvent from an unused documentation-only union
  type - that event no longer exists in the 2.0 API.
- LuaEntityPrototype.max_health is now get_max_health() (quality-aware).
- Fixes a branded-type mismatch between our generated schema's
  ForceIndex and typed-factorio's own ForceIndex.

Verified by actually running tstl end-to-end (clean compile, Lua
emitted) after installing a real JDK and Node toolchain.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-12 15:27:50 +02:00
Lazzexus
a82f1cc392 Port events-mod to Factorio 2.0.77, declare SE/Krastorio 2 compatibility
Bumps the Factorio engine pin and typed-factorio (1.11.0 -> 3.36.0,
targeting 2.0.75) and fixes the resulting breaking API changes:
global -> storage, game.*_prototypes -> prototypes.*, game.table_to_json/
encode_string -> helpers.*, OnBuiltEntityEvent.created_entity -> .entity,
removed TileRead/ColorTable/MapPositionTable-style write-form aliases,
new CollisionMask shape, restructured settings-stage type imports, and
new defines.entity_status values (added to the Status enum, generated
schema, and EntityStatusRecord mapping). Also declares optional mod
dependencies on space-exploration and Krastorio2.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-12 15:06:30 +02:00
Adam
76c47d9756 tidy up after refactoring Gradle Factorio plugin 2022-12-19 16:53:18 +01:00
Adam
a99ed5bb85 remove generated lua (it's stable - moved it to temp dir) 2022-12-19 16:52:49 +01:00
Adam
9f2b9cbd5c big ol' refactor of the Gradle Factorio Mod
- handle launching in multiple OSes
- specific tasks for specific mod operations
- extension object for settings
- ground work for multiple mods
2022-12-18 01:41:14 +01:00
Adam
2c9c442595 typo dequed -> dequeued 2022-12-06 00:24:17 +01:00
Adam
fcb870072a version bumps 2022-12-06 00:23:52 +01:00
Adam
76d553a6bf version 0.10.1 2022-10-30 19:27:50 +01:00
Adam
ce4df2081a bump versions: factorio, typed-factorio 2022-10-30 19:26:43 +01:00
Adam
394acc5ca0 version 0.10.0 2022-10-30 19:22:38 +01:00
Adam
30d5a67a2a update license to be gpl-3.0 2022-10-30 18:58:50 +01:00
Adam
76a661e444 move logo, add function to auto-init the project logo 2022-10-30 18:44:47 +01:00
Adam
f0b080a7fe optimise logo 2022-10-30 18:44:11 +01:00
Adam
ccd08c87c8 version 0.9.15 2022-10-22 23:37:15 +02:00
Adam
51f44f1fd2 version 0.9.14 2022-10-22 20:36:47 +02:00
Adam
14e204d197 version 0.9.13 2022-10-22 20:28:22 +02:00
Adam
bb5e98f740 version 0.9.12 2022-10-22 19:56:33 +02:00
Adam
de24a62635 version 0.9.11 2022-10-18 23:23:09 +02:00
Adam
dda48bac78 refactor the KafkatorioPacket tag that the mod logs, and the syslog-server parses 2022-10-18 21:35:49 +02:00
Adam
b2b6da9c3c version 0.9.9 2022-10-17 00:18:33 +02:00
Adam
6fa5c3f488 [mod] re-build lua (I need to get rid of the lua code and keep at as generated... 2022-10-17 00:17:14 +02:00
Adam
895194d576 [mod] add code for writing packets to file (but disable it) 2022-10-17 00:11:45 +02:00
Adam
8be1fa5025 version 0.9.8 2022-10-16 13:08:04 +02:00
Adam
2032da903f version 0.9.7 2022-10-15 20:42:47 +02:00
Adam
f76eb9ccb3 update events-mod version 2022-10-08 17:06:23 +02:00
Adam
144cbba075 update package.json versions 2022-10-04 23:47:51 +02:00
Adam
f804c39a3b migrate docker-compose convention plugin out of buildSrc 2022-10-02 12:11:06 +02:00
Adam
f12a505d22 migrate buildSrc plugins to includedBuild plugins 2022-09-18 20:49:32 +02:00
Adam
dadbcdd8d6 version bumps (scrimage, kotlinJsWrappers, ktor, hoplite, tstl, typed-factorio, typescript) 2022-09-10 10:13:48 +02:00
Adam
60d61752b3 update mod generated code (remove unused var) 2022-09-01 23:19:06 +02:00
Adam
02edffa2e9 version bump to 0.9.0 (just prepping for the next release) 2022-09-01 23:17:56 +02:00
Adam
b1cf94a8a8 fix item subgroup mapping 2022-09-01 22:57:40 +02:00
Adam
3821996eeb bump some versions (use Kotest in Maven Local b/c plugin isn't available on Sonatype snapshot)
add tile width/height (added in new version of Factorio)
2022-08-28 13:39:34 +02:00
Adam
c9ae17d418 bump versions (kafka, ktor, hoplite, simple-syslog, factorio, tstl, typed-factorio, kotka, gradle-node) and update code to compile 2022-08-13 12:05:17 +02:00
Adam
d9f5d6d46d UpdatePackageJson task is updated based on a json object, and move npm versions to libs.versions.toml 2022-08-13 11:59:30 +02:00
Adam
d006635e49 bump tstl, typed-factorio, ks-js-wrappers 2022-07-23 16:26:11 +02:00
Adam
085776d42b packet size improvements
- change structure resource packets
- make more booleans default to false
- use encode_string - massive decrease in packet size!!
2022-07-17 23:54:53 +02:00
Adam
10c54998c7 version bump to 0.8.0 2022-07-16 23:23:55 +02:00