Repository navigation
Upmerge expressions in the Logic Programmer to 26.3 - #1783
Merged
Merged
Conversation
This allows constant values and multiple nested operators to be combined within a single variable card, without having to combine multiple variable cards. These expressions can either be created through the existing Logic Programmer interface, or they can be written in a text-form for easy exchange across worlds and players.
Ports the expressions of the Logic Programmer (#1766) to Minecraft 26.1: - Client-only classes of the expression panel move to core.logicprogrammer.client, the typed text is kept by the screen instead of the container, and the card facades get client classes for their model overlays. - Expression trees are written with ValueOutput and ValueInput, so values and operators in them are serialized as everywhere else in 26.1. - Values written with their type in the text leave out the "v" field of the serialized value, and items are written as their stack, so the text form is the same as in 1.21, such as @item{id: "minecraft:diamond"}. - Rendering uses GuiGraphicsExtractor, with strata instead of depth for the popups and dragged parameters, and input uses the new event types. - Tests use JUnit 5 and the game test API of 26.1. Unknown items, invalid entity ids and non-compound lists can no longer be read at all, so their error is bad_value instead of value_changed, and an empty entity is written as @entity{}. - The icons of the expression advancements are converted to the 26.1 format, and an unreadable operator makes an expression card invalid instead of throwing, which crashed the book on the Expressions tutorial. - The expression action packet no longer uses @onlyin, which NeoForge 26.1 warns about on every start. Also fixes the invisible operator symbol in the Logic Programmer, which was drawn with color 0, fully transparent since 26.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MHtucHo4Qy2pTfBMgeE54y
Upmerge expressions in the Logic Programmer to 26.1
Ports the expressions of the Logic Programmer to Minecraft 26.3: - Keys and mouse buttons use the SDL codes of InputConstants instead of GLFW. Undo and redo read the shortcut key, so they follow the keyboard layout, and Ctrl, or Cmd on macOS, comes from the key event, as Minecraft#hasControlDown no longer means Cmd on macOS. - The expression text field starts SDL text input when it gets focus, without which no typed characters arrive. - Blocks without properties are written as their id alone in 26.3, so a typed compound with only an id is kept when it is written as that id. - MinMaxBounds, the screen, the left and top of containers, advancement icons and color names follow their 26.3 replacements. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MHtucHo4Qy2pTfBMgeE54y
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merges
master-26-ltsintomaster-26. This brings the Logic Programmer expressions of #1766 and #1781 to Minecraft 26.3. It is a single merge commit.Conflicts
ContainerScreenLogicProgrammerBase.keyPressed:master-26replaced the GLFW key codes withInputConstants, andmaster-26-ltsadded the expression handling of Escape. The result keeps both, withInputConstants.KEY_ESCAPE.CodecsandGameTestsAdvancementshad import conflicts only (ItemPredicateandEntityTypesmoved in 26.3).RenderPattern: both branches fixed the invisible operator symbol in the same way (Fix invisible/miscolored labels and items in logic programmer and display panels #1757 here, and in Upmerge expressions in the Logic Programmer to 26.1 #1781), so it merged cleanly.Porting to 26.3
SDL instead of GLFW
26.3 replaced GLFW with SDL3. Key codes are now SDL scancodes, mouse buttons count from 1, and the modifier masks changed. Most of this compiles either way, so I checked each use rather than relying on the compiler.
InputConstants. Mouse buttons are compared only throughInputConstants.MOUSE_BUTTON_LEFTandMOUSE_BUTTON_RIGHT. No literal button or key numbers are left in the expression code.KeyEvent.shortcutKey(), the semantic key, againstSDLKeycode.SDLK_ZandSDLK_Y. Vanilla does the same for Ctrl+A/C/V/X, so the shortcuts follow the keyboard layout.key()is now the physical key.hasControlDownWithQuirk(), which is Cmd on macOS. On 26.3,Minecraft#hasControlDown()checks only the physical Ctrl keys, where on 26.1 it meant Cmd on macOS. Without this change, Cmd+Left, Cmd+Backspace and the other macOS line keys would have stopped working.KeyEvent.isConfirmation().ExpressionTextFieldis not anEditBox, so it now callsTextInputManager#onTextInputFocusChangewhen it gains or loses focus. Without this, typing into the expression text does nothing on 26.3. The value editor and the other fields areEditBoxes, which already do this.Block literals
In 26.3, the
BlockStatecodec writesidandpropertiesinstead ofNameandProperties. A block without properties is written as its id alone.@Block{id: "minecraft:oak_log", properties: {axis: "x"}}. Without properties, a block prints as@Block"minecraft:stone", which matches how entities already print (@Entity"<uuid>").idthat is written back as the id alone. Without this,@Block{id: "stone"}was rejected as "value changed".@Block "stone"and@Block{id: "stone"}.TestExpressionValueLiterals.testIsKeptcovers the new rule, including that{id: "stoen"}written as"minecraft:air"is still rejected.Other renames
MinMaxBoundsmoved toadvancements.predicates.Minecraft#screenis nowgui.screen().getGuiLeft()andgetGuiTop()are nowgetLeftPos()andgetTopPos().DisplayInfo#getIcon()is nowicon().ChatFormatting.getByNameis gone. Tooltip wrapping maps aTextColorto its format by name instead.Testing
./gradlew build: all 1057 unit tests pass../gradlew runGameTestServer: all 1097 game tests pass, including the expression integration tests.2 * 5 + 4) and[20], and the expression advancements stay granted.ExpressionTextField, and Escape stops it. The value editor's field does the same. I read this fromTextInputManager, since clientdevbridge may inject characters directly.KeyEvents (SDL scancode, keycode and modifiers) through eval:"ab".lto"ab".length()).(x: Integer) => x > 1.@Block "stone" == @Block{id: "stone"} && @Block{id: "oak_log", properties: {axis: "x"}} != @Block "stone"applies as a Boolean, and Format prints it in the forms above.n => n > 10,Integer -> Boolean).hasControlDownWithQuirk().Found, not fixed here
master-26-lts.LabelsWorldStorage.Access#get()returns the client-only instance wheneverMinecraftHelpers#isClientSide()is true. That checks the physical side, so it is true for the integrated server as well.labels.datstays empty, and#labelreferences in expressions stop resolving after a restart.isClientSideThread()is probably what was meant. This code is not touched by the expressions, so I left it for a separate fix.AdvancementButton, as noted in Upmerge expressions in the Logic Programmer to 26.1 #1781.logoFileproperty. They come from those mods, not from this one.Generated by Claude Code