Skip to content

Backport 26.1 compatibility updates to 1.20.1#207

Open
rsdadada wants to merge 6 commits into
xTracr:1.20.1from
rsdadada:codex/sync-26.1-compatible-to-1.20.1
Open

Backport 26.1 compatibility updates to 1.20.1#207
rsdadada wants to merge 6 commits into
xTracr:1.20.1from
rsdadada:codex/sync-26.1-compatible-to-1.20.1

Conversation

@rsdadada
Copy link
Copy Markdown

@rsdadada rsdadada commented May 13, 2026

Overview

  • This PR backports the behavior and internal implementation details from 26.1/dev that are reasonable for Minecraft 1.20.1, Java 17, and the Forge + Fabric architecture, based on the actual origin/1.20.1...HEAD diff.
  • The goal is to reduce the code gap between 1.20.1 and 26.1 while avoiding a mechanical sync of 26.1-only APIs, NeoForge/Kotlin DSL/Java 25/version updates, and the newer rendering submission pipeline.
  • The PR currently contains 6 commits and touches 47 files: common source code, access widener/mixin configuration, language resources, and GitHub issue templates. It does not change Gradle dependency versions or the loader structure, and it raises the 1.20.1 build version to 0.7.8-beta.

Behavior and Configuration Changes

  • Renamed swimOutTick to the more general outTick, used for delaying main-feature recovery after leaving a restricted state. The old config field is kept as a deprecated migration entry point; when old configs are read, the old value is migrated if outTick is still at its default value, then the old field is cleared.
  • Added disableWhenCrawling for bind mode. Swimming and crawling now share the same outTick delay logic. Classic mode still only syncs the swimming exit delay and does not add a crawling toggle.
  • Moved bind-mode disable-related Cloth Config options into the disableConfig subcategory: sneaking, crawling, swimming, outTick, held-item main-feature disable, and held-item rendering disable.
  • Generalized DisableHelper from the swimming-specific swimmingRecently path into checkCondition, and changed wildcard \\*+ splitting to use the precompiled Pattern MULTI_STAR.
  • Synced BindTarget.vanillaTarget's default disablingDepth from 0.1f to 0.2f; BindTarget network/JSON fields and serialVersion remain unchanged.

Binding, Render Capture, and Caching

  • Added RenderTypeCache to centrally manage the texture ID cache and primitive cache, using Guava LoadingCache with maximumSize and expireAfterAccess so long-running sessions do not leave static HashMaps growing without bounds.
  • Texture ID lookup now uses a 1.20.1-compatible mixin accessor/access widener path, reading CompositeRenderType -> CompositeState -> textureState -> cutoutTexture(). It no longer parses RenderType.toString() with a regex. For RenderTypes whose texture cannot be extracted, it still falls back to renderType.toString() as an identifier.
  • Added 3 accessor mixins and declared the required 1.20.1 access permissions in realcamera-common.mixins.json and realcamera.accesswidener.
  • Changed the primitive cache from the old RenderType -> Map<UV, float[]> shape to PrimitiveLayoutKey -> Object2IntMap<UV>, caching the primitive index for each UV. The missing default value is -1.
  • PrimitiveLayoutKey additionally includes texture/render type, draw mode, vertex layout, vertex/primitive count, and mesh ordinal on 1.20.1. This adapts to the older rendering segmentation, where different meshes can share the same RenderType, and avoids incorrectly reusing the coarser 26.1-style cache.
  • Added mode(), vertexLayoutHash(), readPrimitiveAt(int), primitiveLength, and primitiveCount to IterableVertexBuffer, allowing cache hits to read primitives directly by index.
  • BuiltIterableBuffer.resolvePrimitives() now tries cache hits first, then scans only missing UVs. If a cached index is out of bounds or the primitive read from it no longer contains the target UV, it invalidates the current layout cache and falls back to scanning.
  • Removed the old allCached / uvFingerprint path. UV fingerprints are no longer built for every buffer; stale cache entries are handled through read validation and layout-cache invalidation.

YSM and Model Capture

  • YSMCompat still fundamentally simulates 4 player head rotations to match Yes Steve Model binding points; the core idea of matching by simulated head rotation is unchanged.
  • YSM now gives each TransformedVertexRecorder its own MultiVertexCatcher: the first render pass captures buffers and tries cache hits, while the fallback phase reuses those captured buffers to scan missing primitives. Cache misses no longer trigger extra entity renders.
  • Changed resultMap.computeIfAbsent in YSMCompat to the method-reference style and narrowed the recorder into a private final class.
  • Added lifecycle methods create(), clear(), and forEachBuffer() to MultiVertexCatcher; the old endCatching() is kept as a try/finally wrapper to preserve the original "iterate, then release" semantics.
  • Changed RealCameraCore.computeCamera, RealCameraCore.renderCameraEntity, and ModelAnalyser.updateModel to explicitly clean up catchers with try/finally, preventing captured meshes from leaking on exceptional paths.

Geometry Checks and Model View

  • Removed the java.awt.Polygon dependency from BuiltIterableBuffer and ModelAnalyser, replacing it with MathUtil.pointInTriangle / pointInQuad and VertexData.containsUV / containsXY.
  • Added cross, triangle/quad hit tests, fixed-argument floor / ceil helpers to MathUtil, and changed projectToVec2 to take Matrix4fc.
  • VertexData.ImmutableVertex.asImmutable() now directly returns itself; MutableVertex was extracted from an inner VertexData class into a top-level class, reducing implementation weight inside the interface and aligning more closely with the 26.1 structure.
  • Made ModelAnalyser.focusedPolyhedron private and exposed getFocusedPolyhedron(), replaced Object[] with the ZEntry record, and used LongOpenHashSet quantized vertex keys to expand adjacent primitives.
  • Model-click depth sorting keeps the 1.20.1-verified vertex.z() + deltaZ; it does not mechanically adopt the sign change from the 26.1 coordinate convention.
  • Texture-view clicks now inverse-transform the mouse point through the texture pose back into UV space, then run UV hit testing, instead of transforming UVs into screen coordinates and building a Polygon.
  • Made GUIHelper final and synced method names to the shorter outline, triangleOrQuad, and vector forms.

GUI Structure and Key Bindings

  • Moved GUI controls into the com.xtracr.realcamera.gui.components package: TexturedButton -> SimpleIconButton, CyclingTexturedButton -> CycleIconButton, and moved DoubleSlider / NumberField as well.
  • Added NumberWidgetPair, combining an offset/rotation input field and slider into one component. ModelViewScreen no longer maintains 6 duplicated field + slider pairs.
  • The model view still keeps the existing save, delete, import, export, disabled-region selection, and related workflows. This PR only removes the old copy/paste disabled-config controls and their language keys.
  • KeyMappings now uses the new key.category.xtracr_realcamera.general category key, and key handling saves ConfigFile.save() once after any key is consumed during a handle pass instead of saving inside each individual click branch.

Resources and Metadata

  • Added .github/ISSUE_TEMPLATE/bug_report_cn.yml and bug_report_en.yml.
  • Synchronized key ordering across 16 lang JSON files, and added/removed keys to match the code.
  • Added language keys: config.option.*.disableConfig, disableWhenCrawling, outTick, config.tooltip.*.outTick, key.category.*.general, and screen.widget.*.modelView_currentConfig.
  • Removed language keys: config.option.*.swimOutTick, config.tooltip.*.swimOutTick, screen.widget.*.modelView_copy, modelView_paste, screen.tooltip.*.modelView_copy, and modelView_paste.

Explicitly Not Backported

  • Does not sync NeoForge, Kotlin DSL, Java 25, Minecraft 26.1.x dependency versions, or any Gradle build-structure changes. This PR only explicitly raises the 1.20.1 mod_version to 0.7.8-beta.
  • Does not use 26.1's RenderSetup, extractEntity, submit, SubmitNodeStorage, or newer renderer package structure. Those rendering APIs do not exist in 1.20.1, so this PR only backports the ideas of post-capture reuse and cache-hit-first lookup.
  • Does not split the top-level RealCameraConfig structure. This PR only performs field migration and UI grouping to avoid expanding 1.20.1 config-compatibility risk.
  • Does not revert to the old UV -> float[] primitive cache. 1.20.1 uses a layout-scoped primitive-index cache to support the differences in older rendering segmentation.

Compatibility Notes

  • BindTarget.DisableConfig JSON and network serialization fields are unchanged; only the internal UV hit-cache structure is replaced.
  • swimOutTick is preserved as an old config read field and migrated to outTick; the new UI and language keys only expose outTick.
  • The primary texture ID path does not depend on a RenderType.toString() regex; fallback toString() is only used as an identifier for RenderTypes whose texture cannot be extracted.
  • YSM matching semantics are unchanged. The changes are concentrated in buffer capture, cache hits, and miss-path reuse.

Verification

  • .\\gradlew.bat build
  • common:compileJava
  • fabric:validateAccessWidener
  • forge:validateAccessWidener
  • Parsed all lang JSON files as UTF-8
  • git diff --check
  • Checked that no old coarse-grained primitive cache paths remain: allCached, uvFingerprint, RenderType -> Map<UV, Integer>
  • Checked that no old GUI / utility names remain: RenderTypeUtil, old button class names, VertexData.MutableVertex, AWT Polygon

@rsdadada rsdadada changed the title Backport compatible 26.1 updates to 1.20.1 将 26.1 兼容更新回移到 1.20.1 May 13, 2026
@rsdadada rsdadada changed the title 将 26.1 兼容更新回移到 1.20.1 Backport 26.1 compatibility updates to 1.20.1 May 31, 2026
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