mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-27 23:45:52 +00:00
feat: add button orientation API
This commit is contained in:
1 parent
cd13ad6053
commit
59149d7c69
11 files changed
+214
-29
No files matched your search
+6
-4
@@ -64,7 +64,7 @@ The phase checklists include recurring verification rules, historical work and c
|
||||
|
||||
| Workstream | Remaining deliverables | Gate |
|
||||
| --- | --- | --- |
|
||||
| Complete the supported Java surface | Physical-client validation of the documented illuminated microblock example; supported orientation customization for Et Futurum and saw-strength customization for Iguana; finish the audited reflection/legacy-use map | Next FMP milestone; direct typed calls and documented override behavior, without requiring consumer reflection |
|
||||
| Complete the supported Java surface | Physical-client validation of the documented illuminated microblock example; supported saw-strength customization for Iguana; finish the audited reflection/legacy-use map | Next FMP milestone; direct typed calls and documented override behavior, without requiring consumer reflection |
|
||||
| Migrate consumers and adopt releases | Patch GuideNH/Schematica to their documented APIs; migrate ProjectRed's external trait and other Scala/helper users, including OpenComputers, ProjectBlue and ForgeRelocationFMP; direct Galacticraft integration; Et Futurum/Iguana migrations; UtilitiesInExcess enumeration and `mat`/`material` fix; complete the full adoption ledger beyond these hotspots | Source patches, released versions and actual target-pack jars must all be recorded; reference checkouts are not migrated |
|
||||
| Measure and improve performance | Fresh realistic profiles, ranked candidates, bounded improvements and repeated paired measurements; distinguish FMP implementation gains from migrated-consumer gains and report variability/regressions | Phase 4b starts when API/extension workloads are stable; it can overlap consumer adoption |
|
||||
| Validate releases | Complete client rendering/particles/lighting/interaction and integration checklist; old-world, multiplayer, movement and preview checks; packaged/obfuscated artifacts on supported runtimes; optional-mod absent/present loading; actual patched-world MCPC hook where supported | Automated Forge tests do not replace physical-client/full-pack evidence; repeat affected checks after consumer migration and Scala removal |
|
||||
@@ -737,7 +737,7 @@ does not close a row, and scans must distinguish a consumer's own Scala code fro
|
||||
| ProjectRed | Runtime Scala-signature decoding and external trait registration, reached through `MicroblockGenerator.registerTrait(classOf[LightMicroblock])` | Rewrite the ~60-line `LightMicroblock` trait as a Java mixin registered through the `registerJavaTrait` path | FMP compiler prerequisites complete; consumer rewrite and release remain |
|
||||
| Schematica | Private Scala-mangled field `codechicken$multipart$MultiPartRegistry$$typeMap`, cast to `scala.collection.mutable.Map` | `MultiPartRegistry.getPartFactory(String)` is implemented; [guide and example](docs/api/FACTORY_LOOKUP.md). Schematica replaces map/Option lookup with the public method and retains its microblock creation/rejection policy | FMP lookup ready; consumer patch/release/adoption pending |
|
||||
| GuideNH | Companion `MultipartGenerator$.MODULE$.generateCompositeTile` and `MicroblockGenerator$.create`; `partList_$eq(scala.collection.Seq)`; mixin into private `BlockMicroMaterial.block` and `.meta` | Direct Java tile generation/loading, microblock creation and existing `block()` / `meta()` access are documented/tested; [typed material query](docs/api/MATERIAL_ACCESS.md). Remove reflection/accessor mixins when migrating | These FMP paths ready; broader consumer migration/release/adoption pending |
|
||||
| Et Futurum Requiem | Mutable static `int[] ButtonPart.metaSideMap` and `sideMetaMap` must stay public and mutable | FMP exposes a supported orientation-override API; Et Futurum uses it | After step 1 |
|
||||
| Et Futurum Requiem | Mutable static `int[] ButtonPart.metaSideMap` and `sideMetaMap` must stay public and mutable | `ButtonPart.setOrientation(int, ForgeDirection)` is implemented and documented; Et Futurum adopts it | FMP API ready; consumer patch/release/adoption pending |
|
||||
| IguanaTweaksTConstruct | Private `ItemSaw.harvestLevel` field name and type | FMP exposes a supported harvest-level setter; Iguana uses it | After step 1 |
|
||||
| Galacticraft | Selects the first public method named `registerMaterial` without checking its signature, so FMP cannot add any overload of that name | Call `registerMaterial` directly from gated compatibility code; exact-signature reflection is an interim hardening option | Existing public API; consumer migration can start |
|
||||
| UtilitiesInExcess | `MicroMaterialRegistry.getIdMap(): scala.Tuple2[]` | Both call sites read only the name, so `materialCount()` from Phase 9.1 plus the existing `materialName(int)` covers them; no material object is needed | After Phase 9.1, before it enters the pack |
|
||||
@@ -787,8 +787,10 @@ UtilitiesInExcess's `extrautils:*` aliases; there is no legacy-conversion risk i
|
||||
both sides.
|
||||
- [ ] Migrate Galacticraft to direct registration in gated compatibility code; exact-signature reflection is an interim option.
|
||||
- [ ] Fix the UtilitiesInExcess `mat`/`material` key mismatch and its `getIdMap()` use before it enters the pack.
|
||||
- [ ] Add the supported public equivalents needed by Et Futurum and Iguana as additive API. Schematica and GuideNH's
|
||||
identified FMP-side replacements are complete; their consumer migrations remain pending.
|
||||
- [x] Add supported button-orientation mapping for Et Futurum as additive API, preserving the legacy arrays;
|
||||
[guide and example](docs/api/BUTTON_ORIENTATIONS.md). Consumer migration/release/adoption remain pending.
|
||||
- [ ] Add the supported harvest-level setter needed by Iguana as additive API. Schematica and GuideNH's identified
|
||||
FMP-side replacements are complete; their consumer migrations remain pending.
|
||||
- [x] Provide Schematica's registered-factory lookup without exposing the mutable map: `getPartFactory(String)`,
|
||||
with identity/missing-name checks, exact public reflection, a compiling example and the retained private field.
|
||||
This does not complete Schematica's consumer migration.
|
||||
|
||||
@@ -166,6 +166,11 @@ registry-map reflection, with a [migration guide](docs/api/FACTORY_LOOKUP.md). I
|
||||
exact private Scala mutable-map shape and live backing; the public addition does not authorize removing that field
|
||||
before consumer release/adoption. Generator reflection and preview lifecycle remain separate contracts.
|
||||
|
||||
`ButtonPart.setOrientation(int, ForgeDirection): void` now replaces Et Futurum's four reflective array writes and
|
||||
keeps the two direction maps consistent; [guide](docs/api/BUTTON_ORIENTATIONS.md). The existing public mutable static
|
||||
`metaSideMap` and `sideMetaMap` fields retain their exact names, types and modifiers for old releases. Removing or
|
||||
narrowing them still waits for a migrated Et Futurum release, target-pack adoption and a fresh reflective-source scan.
|
||||
|
||||
## Consequences for the migration plan
|
||||
|
||||
1. Phase 8 (Scala runtime removal) should be reclassified as deferred, not scheduled. Decision 4 is answered.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Source-level downstream consumer audit
|
||||
|
||||
Status: 2026-08-27. This is the source-level companion to
|
||||
Status: 2026-09-09. This is the source-level companion to
|
||||
[`JAVA_MIGRATION_ABI_INVENTORY.md`](JAVA_MIGRATION_ABI_INVENTORY.md).
|
||||
|
||||
The ABI inventory answers "what must still link?" This audit answers the harder question: "what behavior do real
|
||||
@@ -407,7 +407,7 @@ added to compatibility CI before it enters the pack.
|
||||
| GT5U | Detects `TileMultipart`, iterates `jPartList`, and finds a ProjectRed `GatePart` to expose its screwdriver slot | Tile identity, Java list view/order, part instance identity |
|
||||
| EnderCore | Tests items with `instanceof ItemSaw` for durability display | `ItemSaw` class identity and inheritance |
|
||||
| IguanaTweaksTConstruct | Creates saws through `MicroblockProxy`, reads saw methods, accesses proxy companions, and reflectively mutates private `ItemSaw.harvestLevel` | Proxy methods and `MODULE$`, `Saw`/`ItemSaw` identity, exact `harvestLevel: int` field name/type |
|
||||
| Et Futurum Requiem | Reflectively gets and mutates static `int[] ButtonPart.metaSideMap` and `sideMetaMap` to repair button orientation | Exact class and mutable static field names/types; array index meanings |
|
||||
| Et Futurum Requiem | Reflectively gets and mutates static `int[] ButtonPart.metaSideMap` and `sideMetaMap` to add floor and ceiling orientation | Exact class and mutable static field names/types until migration; `ButtonPart.setOrientation` is the supported replacement |
|
||||
|
||||
## Source-only hazards that must be added to the compatibility checklist
|
||||
|
||||
@@ -418,16 +418,17 @@ requirements:
|
||||
| --- | --- | --- |
|
||||
| Schematica | `MultiPartRegistry$.MODULE$`; field `codechicken$multipart$MultiPartRegistry$$typeMap` of Scala mutable-map shape; exact generator/load methods | FMP schematic tile reconstruction disables itself or returns no preview |
|
||||
| GuideNH | Companion-only generator methods; `partList_$eq(Seq)`; `BlockMicroMaterial.block` and `.meta` mixin fields | Missing/incorrect guide preview, material export, or part statistics |
|
||||
| Et Futurum | Static mutable `ButtonPart.metaSideMap` and `sideMetaMap`, both `int[]` | FMP buttons attach with pre-fix orientation behavior |
|
||||
| Et Futurum | Static mutable `ButtonPart.metaSideMap` and `sideMetaMap`, both `int[]`, until direct API adoption | FMP buttons attach with pre-fix orientation behavior |
|
||||
| Iguana | Private `ItemSaw.harvestLevel` field | Existing saw cutting strengths are not adjusted |
|
||||
| Galacticraft | Reflection by method name only for `registerMaterial` | Galacticraft micro-material registration is skipped after a caught exception |
|
||||
| Waila | `BlockMultipart` string plus tile NBT `parts`/part `id` | No multipart HUD data |
|
||||
|
||||
These need targeted runtime tests or explicit downstream patches. They cannot be proven safe by `javap` ABI diffing.
|
||||
|
||||
**Current branch:** `ConsumerReflectionCompatibilityTest` now freezes the GuideNH, Et Futurum, Iguana, and
|
||||
Galacticraft member shapes above. Schematica's registry lookup has its own live-view regression test. The manual client
|
||||
checks remain necessary for end-to-end integration behavior.
|
||||
**Current branch:** `ConsumerReflectionCompatibilityTest` freezes the GuideNH, Et Futurum, Iguana, and Galacticraft
|
||||
member shapes above. `ButtonOrientationFunctionalTest` also freezes Et Futurum's exact array mutation and all-face
|
||||
placement, then verifies the supported typed replacement. Schematica's registry lookup has its own live-view regression
|
||||
test. The manual client checks remain necessary for end-to-end integration behavior.
|
||||
|
||||
## Data and ordering contracts
|
||||
|
||||
@@ -529,9 +530,15 @@ tied to a released minimum dependency version. Unlisted contracts remain governe
|
||||
| `MultipartGenerator$.generateCompositeTile(TileEntity, scala.collection.Iterable, boolean)` | Schematica `3b03ee937953` exact reflection; GuideNH `7d8fb44e77b9` static-first assignability matcher | Static `MultipartGenerator.generateCompositeTile(TileEntity, java.lang.Iterable, boolean)` with Java parts; retain subsequent state setup/loading | Source patches/releases pending; preserve client part construction, candidate-reuse branch and notification order | No migrated pack version verified; retain the companion and Scala descriptor |
|
||||
| `MicroblockGenerator$.create(MicroblockClass, int, boolean)` exact reflection and private shape copy | GuideNH `7d8fb44e77b9`: `getMicroblockGeneratorCreate`, `promoteMicroblockToClient` | Existing static `MicroblockGenerator.create` with the same parameter types/order; recreate family/material and restore encoded shape through public API | Source patch/release pending; guide/example tested on server, physical client and custom shape-setter overrides require adoption checks | No migrated pack version verified; retain companion singleton and exact descriptor |
|
||||
| Private `BlockMicroMaterial.block` / `meta` accessor mixin and reflective material query | GuideNH `7d8fb44e77b9`: `AccessorBlockMicroMaterial`, `resolvePrimaryMicroblockId` | Direct `jPartList()`, `Microblock.material()`, `getMaterial(int)`, `BlockMicroMaterial.block()` / `meta()`; [typed example](docs/api/MATERIAL_ACCESS.md) | Source patch/release pending; remove mixin, retain export filtering/failure policy, validate getter overrides and optional loading | No migrated pack version verified; retain private fields |
|
||||
| Reflective mutation of `ButtonPart.metaSideMap` / `sideMetaMap` | Et Futurum Requiem `78a5744dfd33`: `compat.CompatMisc.runModHooksInit` | Two direct `ButtonPart.setOrientation(int, ForgeDirection)` calls; [mapping and lifecycle guide](docs/api/BUTTON_ORIENTATIONS.md) | FMP API/example complete; consumer source patch and first released version pending | Retain both public mutable arrays until the migrated release is in the target pack and a fresh scan confirms no legacy access |
|
||||
| `NormalOcclusionTest$.apply(Traversable, Traversable)` | OpenComputers `2c00f79be24b`: `common.block.Cable.canConnectFromSideFMP`, `server.network.Network.canConnectFromSideFMP` | `NormalOcclusionTest.testBoxes(ownBounds.asJava, otherBounds)`; `otherBounds` already comes from Java `getOcclusionBoxes()` | Source patch and release pending; retain side/color/face filtering | No migrated pack version verified; retain the companion and descriptor |
|
||||
| `NormalOcclusionTest$.apply(Traversable, Traversable)` | ForgeRelocationFMP `49a810b8c63b`: `FramePart.occlusionTest` | `NormalOcclusionTest.testBoxes(boxes.asJava, getOcclusionBoxes)`; retain combined normal/partial/collision boxes and caller order | Source patch and release pending; preserve temporary face bounds and replacement protocol | No migrated pack version verified; retain the companion and descriptor |
|
||||
|
||||
Button orientation evidence is under ignored `run/migration-button-orientation-reference/`. Baseline commit `cd13ad6`
|
||||
freezes Et Futurum's exact four array writes and all-face placement before the API addition. The supported setter keeps
|
||||
the two maps one-to-one and validates inputs, while the Java example compiles against the dev artifact without Scala or
|
||||
reflection. The reference checkout remains unchanged; no consumer migration, release or target-pack adoption is claimed.
|
||||
|
||||
Evidence for the FMP addition is under ignored `run/migration-material-enumeration-reference/`. The original
|
||||
reference-compiled Scala consumer still exercises the companion and tuple-array descriptor. The new compiling Java
|
||||
example has no Scala imports or bytecode references. Runtime checks cover initialized ID lookup and handshake order;
|
||||
|
||||
+19
-16
@@ -17,7 +17,7 @@ migration checkout; `codex/tile-compatibility-fixes` was deleted after its fixes
|
||||
|
||||
## Current state and next target
|
||||
|
||||
**573 plain-JVM tests and 287 Java 8 Forge tests pass, with zero failures/errors/skips.** Sources total **225 Java
|
||||
**573 plain-JVM tests and 289 Java 8 Forge tests pass, with zero failures/errors/skips.** Sources total **225 Java
|
||||
files and 9 Scala files / 747 nonblank Scala lines**. The packaged inventory has 444 classes.
|
||||
|
||||
Review follow-up: restored packet-scheduler callback mutation behavior with the original Scala hash-map traversal,
|
||||
@@ -32,15 +32,18 @@ use, but no override triggering these three regressions was found. All 443 class
|
||||
payloads and 116 generated dumps are retained. The agreed next milestone is the documented consumer-facing Java API,
|
||||
followed by consumer release/adoption and final Scala removal; see the plan's API migration design and Phases 8–10.
|
||||
|
||||
Latest API work documents [custom Java tile-trait authoring](docs/api/CUSTOM_TILE_TRAITS.md) over the existing
|
||||
`MultipartGenerator.registerTrait` overloads. Baseline commit `d98e48f` adds a compiling four-type example and real
|
||||
Forge registration. It separates the requesting part marker, stable caller capability, transformed input and ordinary
|
||||
helper, then verifies generated server/client tiles, aggregation, binding, exact reuse and class caching. The example
|
||||
uses derived state, so it needs no new cache, NBT or packet contract. No production method body or descriptor changed.
|
||||
All 573 JVM / 287 Forge tests pass, including the frozen baseline callers. All 444 classes, 17 ScalaSignature payloads,
|
||||
3,763 packaged methods and 134 generated dumps retain their executable shape. Evidence:
|
||||
`run/migration-custom-tile-trait-reference/`. No supplied consumer directly registers a custom multipart tile trait;
|
||||
this is supported extension coverage, not consumer adoption.
|
||||
Latest API work adds [supported multipart button orientation mapping](docs/api/BUTTON_ORIENTATIONS.md). Et Futurum
|
||||
Requiem `78a5744dfd33` currently reflects `ButtonPart.metaSideMap` and `sideMetaMap`, then writes the missing floor and
|
||||
ceiling pairs. Baseline commit `cd13ad6` freezes the default maps, those exact four writes and placement metadata on all
|
||||
six faces. `ButtonPart.setOrientation(int, ForgeDirection)` performs the same update through one validated public API,
|
||||
keeps both maps one-to-one when replacing a pair and rejects invalid input before mutation. Its compiling example uses
|
||||
two direct common-initialization calls without Scala or reflection.
|
||||
|
||||
All 573 JVM / 289 Forge tests pass; 573 archived JVM and 287 archived Forge callers also pass. All 444 production
|
||||
classes and 17 ScalaSignature payloads remain. The 3,763 old methods are unchanged and one public static method is
|
||||
added; all 134 generated dumps match by name and hash. The mutable arrays retain their exact public static shape for
|
||||
old Et Futurum releases. Consumer patch/release/pack adoption and physical-client validation remain open. Evidence:
|
||||
`run/migration-button-orientation-reference/`.
|
||||
|
||||
Direct typed calls are the intended end state for supported integrations. Optional dependencies should isolate typed
|
||||
compatibility code behind presence/version checks; reflection snippets in earlier guides are temporary legacy
|
||||
@@ -64,17 +67,17 @@ adoption remain pending. Checkouts remain reference-only. The installed `+719` p
|
||||
Java surface; supply missing capabilities, precise contracts, migration guidance and compiling examples. Cover
|
||||
subclass/override behavior and generated extensions as well as ordinary calls. ProjectRed's illuminated microblocks
|
||||
are the representative external extension case. Consumer mods may remain Scala internally while adopting this API.
|
||||
The next bounded candidate is a supported orientation customization API for Et Futurum, replacing its mutation of
|
||||
`ButtonPart.metaSideMap` and `sideMetaMap`, with exact mapping and placement coverage. Other audited reflection use
|
||||
cases remain separate work.
|
||||
The next bounded candidate is a supported saw-strength setter for Iguana, replacing its reflection into private
|
||||
`ItemSaw.harvestLevel`. Other audited reflection use cases remain separate work.
|
||||
Converter registration/lifecycle and stable tile capability access guidance are complete.
|
||||
The illuminated microblock example supplies the representative Java extension, but physical-client construction,
|
||||
connector-dependent halos, lighting and consumer adoption still need their recorded checks.
|
||||
|
||||
Progress: all ten Phase 9.1 table rows and Phase 9.2's internal markers are complete, plus Schematica registry lookup,
|
||||
staged Java tile generation, microblock creation, typed material access, the Java illuminated extension example, slot
|
||||
refresh and custom Java tile-trait authoring. Remaining work includes other audited reflection use cases. Consumer patches,
|
||||
releases and pack adoption still precede final Scala removal and client/pack release validation.
|
||||
refresh, custom Java tile-trait authoring and button orientation mapping. Iguana's saw-strength access is the remaining
|
||||
bounded FMP-side reflection replacement. Consumer patches, releases and pack adoption still precede final Scala
|
||||
removal and client/pack release validation.
|
||||
|
||||
Extra Utilities remains an active supported consumer. UtilitiesInExcess is the intended replacement, but the support
|
||||
switch awaits approval and actual target-pack adoption. Retain existing contracts until those gates pass. The
|
||||
@@ -155,7 +158,7 @@ test world triggers Forge's missing-mapping prompt. Restore server.properties af
|
||||
|
||||
Generated dumps: `run/server/asm/multipart/**/*.txt`; enumerate recursively and assert a nonzero expected count.
|
||||
Compare names and hashes first. Investigate differences before normalizing only proven debug/private-name changes.
|
||||
The current baseline emits 130 dumps, including the deterministic definition, compiler and feature fixtures.
|
||||
The current baseline emits 134 dumps, including the deterministic definition, compiler and feature fixtures.
|
||||
|
||||
### Binary and fixture checks
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ entries complete.
|
||||
| [ ] | Place and break OpenComputers **Cable** and a **3D Print**, ProjectBlue **Control Panel** (size suffix varies), and AE2 **ME Glass Cable**; share their block space with a compatible cover | No `NoSuchMethodError` or `AbstractMethodError` in the log | retained `$class` bridges |
|
||||
| [ ] | Load and render a schematic containing an ordered mixed multipart tile | Every part appears in the preview in the saved order; the integration does not silently disable itself | Schematica private registry-map reflection, `MicroblockClass.create`, and tile NBT reconstruction |
|
||||
| [ ] | Open a GuideNH scene containing a multipart tile and export its part/material data | The preview, material data and part statistics are complete | companion reflection, `MicroblockGenerator$.create`, `Microblock.microClass/material/shape`, `partList_$eq`, and `BlockMicroMaterial` mixin fields |
|
||||
| [ ] | Place FMP buttons on every supported face with Et Futurum loaded | Button orientation matches the fixed vanilla behavior | reflected mutable `ButtonPart` side/meta arrays |
|
||||
| [ ] | Place FMP buttons on every supported face with Et Futurum loaded | Button orientation matches the fixed vanilla behavior | supported `ButtonPart.setOrientation`; legacy arrays until consumer adoption |
|
||||
| [ ] | Use OpenComputers **3D Printer** to make a **3D Print** with different off/on shapes that both fit beside a cover; place it with the cover and right-click to toggle | Its slots are rebuilt without losing, hiding or disconnecting either part | external mutation of `TSlottedTile.v_partMap` plus `bindPart` |
|
||||
| [ ] | Move the same composite tile using a ProjectRed **Frame Motor** with MCFrames **Frame** blocks, then a **Matter Manipulator MKIII** in move mode | Coordinates, part-to-tile references, generated interfaces and rendering remain correct after `onMoved` | ForgeRelocationFMP / MatterManipulator live multipart move lifecycle |
|
||||
| [ ] | Inspect a mixed multipart tile with Waila | Providers receive every saved part ID and show the expected part data | reflected block identity and tile NBT `parts`/`id` layout |
|
||||
|
||||
+5
-2
@@ -39,6 +39,7 @@ Existing reflective binaries remain supported until consumer release and pack ad
|
||||
| Test two groups of bounding boxes directly | `NormalOcclusionTest.testBoxes(Iterable, Iterable)` — [box-versus-box queries](api/OCCLUSION.md#box-versus-box-queries) |
|
||||
| Read FMP's global render registration ID | `TileMultipart.getRenderID()` — [render-ID meaning, lifecycle and setter](api/RENDER_ID.md) |
|
||||
| Inspect an existing tile or converted placeholder with a named result | `getOrConvertTileResult(World, BlockCoord)` — [conversion outcomes and placement lifecycle](api/TILE_CONVERSION.md) |
|
||||
| Add or remap multipart button attachment orientations | `ButtonPart.setOrientation(int, ForgeDirection)` — [metadata, face mapping and Et Futurum migration](api/BUTTON_ORIENTATIONS.md) |
|
||||
|
||||
Each guide explains ownership, lifecycle, legacy replacements and limitations, and links to a compiling Java example
|
||||
exercised by the test suite. The loading/setter APIs are advanced reconstruction operations; ordinary placement and
|
||||
@@ -115,8 +116,10 @@ light aggregation and halo geometry, with compiling examples and Forge coverage.
|
||||
ProjectRed adoption remain open. [Converter registration and lifecycle](api/BLOCK_CONVERTERS.md) are documented and
|
||||
tested. [Stable tile capability access](api/TILE_TRAIT_ACCESS.md) covers safe Java calls, ProjectRed redstone queries
|
||||
and OpenComputers slot refresh. [Custom Java tile-trait authoring](api/CUSTOM_TILE_TRAITS.md) covers registration,
|
||||
stable capabilities, lifecycle/state rules and transformer constraints with generated Forge coverage. The remaining
|
||||
audited reflection replacements are still pending. ProjectRed's existing Scala traits remain supported until adoption.
|
||||
stable capabilities, lifecycle/state rules and transformer constraints with generated Forge coverage. Supported
|
||||
[button orientation mapping](api/BUTTON_ORIENTATIONS.md) replaces Et Futurum's reflective array mutation. The Iguana
|
||||
saw-strength setter remains the audited FMP-side reflection gap. ProjectRed's existing Scala traits remain supported
|
||||
until adoption.
|
||||
|
||||
All ten entries in the plan's Phase 9.1 API table have Java replacements. That table is a bounded list of signatures;
|
||||
the broader API, extension and consumer adoption work above remains open.
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# Multipart button orientations
|
||||
|
||||
[Java API index](../API.md)
|
||||
|
||||
`ButtonPart.setOrientation(int, ForgeDirection)` maps a button's orientation metadata to the multipart face it
|
||||
occupies. It updates the metadata-to-face and face-to-metadata lookups together, so placement, face slots, support
|
||||
checks and strong redstone output continue to agree.
|
||||
|
||||
Et Futurum Requiem can enable its floor and ceiling button metadata during common initialization with direct calls:
|
||||
|
||||
```java
|
||||
ButtonPart.setOrientation(0, ForgeDirection.UP);
|
||||
ButtonPart.setOrientation(5, ForgeDirection.DOWN);
|
||||
```
|
||||
|
||||
The [compiling example](../../src/functionalTest/java/codechicken/multipart/examples/ButtonOrientationExample.java)
|
||||
contains the same two calls. Keep FMP-typed code in an optional compatibility class loaded only after the usual
|
||||
mod-presence and supported-version checks.
|
||||
|
||||
## Metadata and face meaning
|
||||
|
||||
Pass only the orientation metadata from the low three bits, from `0` through `7`. Do not include bit `8`, which records
|
||||
the pressed state, or bit `16`, which selects a wooden button. The face is the standard Forge direction returned by
|
||||
`ButtonPart.getFace()`: `UP` for a ceiling button and `DOWN` for a floor button. `UNKNOWN`, `null` and out-of-range
|
||||
metadata are rejected with `IllegalArgumentException` before either map changes.
|
||||
|
||||
The mapping is one-to-one. Setting an existing metadata value to another face clears its old reverse entry; assigning
|
||||
a face already used by another metadata value clears that old forward entry. Repeating an existing pair is harmless.
|
||||
|
||||
Call the method during common mod initialization on each physical side, before worlds load button parts or players can
|
||||
place them. The mappings are process-global. Changing one later also changes how existing button metadata is
|
||||
interpreted for slots, support and redstone notification, so runtime reconfiguration is unsupported.
|
||||
|
||||
This method does not define a vanilla button block's bounds. `ButtonPart` captures all 16 button block bounds during
|
||||
class initialization, after normal class transformations; a mod adding metadata orientations must still make its
|
||||
button block expose the matching bounds.
|
||||
|
||||
## Migrating Et Futurum Requiem
|
||||
|
||||
Replace the reflective reads, four array writes and reflective field assignments with the two calls above. Do not
|
||||
catch and ignore API failures: an invalid metadata or direction is a configuration error that should remain visible.
|
||||
Keep Et Futurum's existing FMP presence/version gate so older FMP versions never load the typed compatibility class.
|
||||
|
||||
The public mutable `metaSideMap` and `sideMetaMap` fields remain binary and reflective compatibility surfaces for old
|
||||
releases. New integrations should not read, replace or mutate them directly. Their removal still requires a released
|
||||
Et Futurum migration, target-pack adoption and a fresh consumer scan.
|
||||
|
||||
## Validation
|
||||
|
||||
Forge characterization first freezes the old Et Futurum mutation and verifies exact metadata and placement on all six
|
||||
faces. API tests verify the two direct calls produce the same arrays, displaced pairs remain one-to-one, invalid input
|
||||
is atomic, and the example compiles. A physical client with Et Futurum must still complete the
|
||||
[all-face button check](../../JAVA_MIGRATION_MANUAL_CHECKS.md) before release.
|
||||
@@ -2178,3 +2178,25 @@ differences belong in the [divergence ledger](../../JAVA_MIGRATION_DIVERGENCES.m
|
||||
`run/migration-custom-tile-trait-reference/`.
|
||||
- Next bounded task: expose supported button-orientation customization for Et Futurum, then cover Iguana's saw-strength
|
||||
customization. Consumer adoption, physical-client/full-pack checks and measured performance remain separate gates.
|
||||
|
||||
### 2026-09-09 — Supported multipart button orientations
|
||||
|
||||
- Inspected Et Futurum Requiem at `78a5744dfd33`. Its initialization hook reflectively obtains the two public static
|
||||
`ButtonPart` direction arrays, writes metadata `0` to `UP` and metadata `5` to `DOWN` in both directions, then catches
|
||||
every exception. No other supplied consumer mutates these maps.
|
||||
- Committed baseline `cd13ad6` before the production change. Its Forge test freezes the default arrays, the consumer's
|
||||
exact four writes, unavailable vertical placement before them and all six metadata-to-face placement results after.
|
||||
- Added `ButtonPart.setOrientation(int, ForgeDirection)`. It validates orientation metadata and cardinal faces before
|
||||
mutation, updates both existing arrays in place and clears displaced inverse entries so remapping stays one-to-one.
|
||||
The arrays keep their exact public mutable static field shape for old consumer binaries and reflection.
|
||||
- Added the [button orientation guide](../api/BUTTON_ORIENTATIONS.md) and compiling example. Et Futurum can replace its
|
||||
reflection with two direct common-initialization calls. Bounds still come from the transformed vanilla button block;
|
||||
consumer patch/release/pack adoption and physical-client all-face validation remain open.
|
||||
- Normal and clean formatting/checkstyle/build/Forge validation passes with **573 JVM / 289 Forge** tests, zero
|
||||
failures/errors/skips. All **573 archived JVM / 287 archived Forge** callers pass. The example compiles on Java 8
|
||||
against the dev artifact with no Scala classpath or bytecode reference, and all 146 local documentation links resolve.
|
||||
- The packaged inventory remains **444 classes** and **17 ScalaSignature payloads**. All **3,763 existing methods** are
|
||||
unchanged and exactly one public static method is added. All **134 generated dumps** match the baseline by name and
|
||||
SHA-256. Evidence: `run/migration-button-orientation-reference/`.
|
||||
- Next bounded task: expose supported saw-strength customization for Iguana. Consumer adoption, physical-client/full-pack
|
||||
checks and measured performance remain separate gates.
|
||||
@@ -0,0 +1,17 @@
|
||||
package codechicken.multipart.examples;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import codechicken.multipart.minecraft.ButtonPart;
|
||||
|
||||
/** Forge-tested compiling example for docs/api/BUTTON_ORIENTATIONS.md. */
|
||||
public final class ButtonOrientationExample {
|
||||
|
||||
private ButtonOrientationExample() {}
|
||||
|
||||
/** Enables the floor and ceiling metadata supplied by Et Futurum Requiem's button extension. */
|
||||
public static void registerVerticalOrientations() {
|
||||
ButtonPart.setOrientation(0, ForgeDirection.UP);
|
||||
ButtonPart.setOrientation(5, ForgeDirection.DOWN);
|
||||
}
|
||||
}
|
||||
+35
@@ -4,15 +4,18 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import codechicken.lib.vec.BlockCoord;
|
||||
import codechicken.multipart.examples.ButtonOrientationExample;
|
||||
import codechicken.multipart.minecraft.ButtonPart;
|
||||
|
||||
class ButtonOrientationFunctionalTest {
|
||||
@@ -64,6 +67,38 @@ class ButtonOrientationFunctionalTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void typedApiMatchesEtFuturumAndKeepsMappingsOneToOne() {
|
||||
int[] originalMetaSideMap = ButtonPart.metaSideMap;
|
||||
int[] originalSideMetaMap = ButtonPart.sideMetaMap;
|
||||
int[] originalMetaSideValues = originalMetaSideMap.clone();
|
||||
int[] originalSideMetaValues = originalSideMetaMap.clone();
|
||||
|
||||
try {
|
||||
ButtonOrientationExample.registerVerticalOrientations();
|
||||
assertArrayEquals(new int[] { 1, 4, 5, 2, 3, 0, -1, -1 }, ButtonPart.metaSideMap);
|
||||
assertArrayEquals(new int[] { 5, 0, 3, 4, 1, 2 }, ButtonPart.sideMetaMap);
|
||||
|
||||
ButtonPart.setOrientation(1, ForgeDirection.DOWN);
|
||||
assertArrayEquals(new int[] { 1, 0, 5, 2, 3, -1, -1, -1 }, ButtonPart.metaSideMap);
|
||||
assertArrayEquals(new int[] { 1, 0, 3, 4, -1, 2 }, ButtonPart.sideMetaMap);
|
||||
|
||||
int[] metaSideValues = ButtonPart.metaSideMap.clone();
|
||||
int[] sideMetaValues = ButtonPart.sideMetaMap.clone();
|
||||
assertThrows(IllegalArgumentException.class, () -> ButtonPart.setOrientation(-1, ForgeDirection.UP));
|
||||
assertThrows(IllegalArgumentException.class, () -> ButtonPart.setOrientation(8, ForgeDirection.UP));
|
||||
assertThrows(IllegalArgumentException.class, () -> ButtonPart.setOrientation(0, null));
|
||||
assertThrows(IllegalArgumentException.class, () -> ButtonPart.setOrientation(0, ForgeDirection.UNKNOWN));
|
||||
assertArrayEquals(metaSideValues, ButtonPart.metaSideMap);
|
||||
assertArrayEquals(sideMetaValues, ButtonPart.sideMetaMap);
|
||||
} finally {
|
||||
System.arraycopy(originalMetaSideValues, 0, originalMetaSideMap, 0, originalMetaSideMap.length);
|
||||
System.arraycopy(originalSideMetaValues, 0, originalSideMetaMap, 0, originalSideMetaMap.length);
|
||||
ButtonPart.metaSideMap = originalMetaSideMap;
|
||||
ButtonPart.sideMetaMap = originalSideMetaMap;
|
||||
}
|
||||
}
|
||||
|
||||
private static void prepareSupports(World world) {
|
||||
clear(world);
|
||||
for (int side = 0; side < 6; side++) {
|
||||
|
||||
@@ -20,7 +20,13 @@ public class ButtonPart extends McSidedMetaPart implements IFaceRedstonePart {
|
||||
|
||||
public static BlockButton stoneButton = (BlockButton) Blocks.stone_button;
|
||||
public static BlockButton woodenButton = (BlockButton) Blocks.wooden_button;
|
||||
|
||||
/** Legacy mutable mapping retained for existing integrations; new code should use {@link #setOrientation}. */
|
||||
public static int[] metaSideMap = new int[] { -1, 4, 5, 2, 3, -1, -1, -1 };
|
||||
|
||||
/**
|
||||
* Legacy mutable inverse mapping retained for existing integrations; new code should use {@link #setOrientation}.
|
||||
*/
|
||||
public static int[] sideMetaMap = new int[] { -1, -1, 3, 4, 1, 2 };
|
||||
public static Cuboid6[] cuboidRegions = setupCuboids();
|
||||
|
||||
@@ -46,6 +52,38 @@ public class ButtonPart extends McSidedMetaPart implements IFaceRedstonePart {
|
||||
return regions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the attachment face represented by a button's orientation metadata.
|
||||
*
|
||||
* <p>
|
||||
* Call this during common mod initialization, before button parts are loaded or placed. This updates both placement
|
||||
* and metadata lookups and removes any previous inverse mappings displaced by the new pair.
|
||||
*
|
||||
* @param metadata the orientation bits, from 0 through 7; do not include the pressed or button-type bits
|
||||
* @param attachmentFace the face occupied by the multipart button
|
||||
* @throws IllegalArgumentException if the metadata or face is outside its supported range
|
||||
*/
|
||||
public static void setOrientation(int metadata, ForgeDirection attachmentFace) {
|
||||
if (metadata < 0 || metadata > 7) {
|
||||
throw new IllegalArgumentException("Button orientation metadata must be between 0 and 7: " + metadata);
|
||||
}
|
||||
if (attachmentFace == null || attachmentFace == ForgeDirection.UNKNOWN) {
|
||||
throw new IllegalArgumentException("Button attachment face must be one of the six cardinal directions");
|
||||
}
|
||||
|
||||
int side = attachmentFace.ordinal();
|
||||
int previousSide = metaSideMap[metadata];
|
||||
if (previousSide >= 0 && previousSide < sideMetaMap.length && sideMetaMap[previousSide] == metadata) {
|
||||
sideMetaMap[previousSide] = -1;
|
||||
}
|
||||
int previousMetadata = sideMetaMap[side];
|
||||
if (previousMetadata >= 0 && previousMetadata < metaSideMap.length && metaSideMap[previousMetadata] == side) {
|
||||
metaSideMap[previousMetadata] = -1;
|
||||
}
|
||||
metaSideMap[metadata] = side;
|
||||
sideMetaMap[side] = metadata;
|
||||
}
|
||||
|
||||
public static BlockButton getButton(int meta) {
|
||||
return (meta & 0x10) > 0 ? woodenButton : stoneButton;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user