Add OpenComputers drivers for Create's pulley, piston, and bearing blocks - #56
Conversation
…ocks Adds direct block-adjacent OC drivers for five vanilla Create blocks that previously had no OpenComputers support at all (only reachable indirectly via Create: Crafts & Additions' Digital Adapter as CC:Tweaked peripherals): - Create_ElevatorPulley: getPulleyDistance, getElevatorFloor, getElevatorFloors, getElevatorFloorName, hasElevatorArrived, gotoElevatorFloor (the only mutating method here). - Create_MechanicalBearing: getBearingAngle. - Create_RopePulley: getPulleyDistance. - Create_HosePulley: getPulleyDistance. - Create_MechanicalPiston: getPistonDistance, isSticky. All read-only except gotoElevatorFloor. ElevatorPulleyBlockEntity extends PulleyBlockEntity (rope pulley's class), so the RopePulley driver is registered with a predicate excluding ElevatorPulleyBlockEntity instances, avoiding a redundant Create_RopePulley component alongside Create_ElevatorPulley on actual elevator pulleys. MechanicalPistonBlockEntity is a sibling of PulleyBlockEntity under LinearActuatorBlockEntity; HosePulleyBlockEntity is an unrelated class extending KineticBlockEntity directly. Three separate driver classes, since only their offset-reading method happens to share a signature - the blocks themselves are distinct. Sticky and regular Mechanical Piston share the exact same MechanicalPistonBlockEntity class; the distinction lives on the registered Block instance (create:sticky_mechanical_piston vs. create:mechanical_piston) rather than the block entity, so isSticky reads it via MechanicalPistonBlock.isStickyPiston(BlockState).
|
Closing per the CONTRIBUTING.md guidance - same reasoning as #55, this belongs upstream in Create rather than here. |
That is a weird thing for you to have chosen to do? I feel like it would have been easier for you to have searched through the source code instead of groveling through bytecode. Did you accidentally forget to disclose any use of AI used in this PR (not required at the time of submission, but would have been an appreciated courtesy)? |
|
Used a decompiler against the compiled Create jar since I didn't have mapped/deobfuscated source for that class handy - standard when working against a compiled dependency rather than a source checkout. The class hierarchy finding held up either way. Hello there. I just gave up. Have a great day. |
|
Sorry, I don't quite understand? This is useful work to include because Create is one of the mods that we do provide direct driver support for, as one of the few exceptions to the guidelines about drivers for other mods not living in the OpenComputers mod. |
|
Sorry, that came out confusing - I've never really contributed on GitHub before and worded that badly. The "gave up" part wasn't about this PR, it was frustration bleeding through from nearly a week spent fixing what I fixed here. Didn't mean to imply anything about the work itself. Reopening - thanks for clarifying Create is a supported exception. |
|
Ah, your comment was amended to clarify the bytecode groveling. My apologies on that front; I've been accused of using AI when I didn't at all and also found it deeply frustrating. It's a fine line to walk trying to suss out whether something is or isn't AI-generated when you're not sure. >.< |
|
No worries, appreciate you being straight up about it. Working on something with this that hasn't really been done in Minecraft before - can't say more yet, but the fork's public if you're ever curious how deep the rabbit hole goes. 🐰 |
What
Adds OC drivers for five vanilla Create blocks with direct block-adjacent Adapter attachment: Elevator Pulley, Mechanical Bearing, Rope Pulley, Hose Pulley, and Mechanical Piston.
Why
No existing OC support for any of these blocks — they were only reachable indirectly via Create: Crafts & Additions' Digital Adapter as CC:Tweaked peripherals, with no OC equivalent.
Implementation
Five separate
CreateEnvironment<T>classes in a new file,CreateContraptionEnvironments.java, each matched on its concrete block-entity type viaCreateBlockDriver<>inCreateDrivers.java— the same pattern already used for the existingCreate_Speedometer/Create_Stressometer/etc. drivers.Class hierarchy note, confirmed via direct bytecode inspection of the Create 6.0.10 jar:
ElevatorPulleyBlockEntity extends PulleyBlockEntity(the Rope Pulley's own class). A driver matched naively onPulleyBlockEntitywould therefore also fire on actual elevator pulleys viainstanceof, producing a redundantCreate_RopePulleyalongsideCreate_ElevatorPulleyon the same block. TheRopePulleydriver is registered with a predicate excludingElevatorPulleyBlockEntityinstances (mirroring the existingPackager/RepackagerBlockEntityexclusion pattern already in this file) to avoid that.MechanicalPistonBlockEntityis a sibling ofPulleyBlockEntityunder a sharedLinearActuatorBlockEntityparent (explains why both exposegetInterpolatedOffset), whileHosePulleyBlockEntityextendsKineticBlockEntitydirectly — an unrelated branch. Kept as three separate driver classes rather than one shared driver: the blocks are genuinely distinct, and only their single offset-reading method happens to share a signature.Sticky piston note: Sticky Mechanical Piston and regular Mechanical Piston share the exact same
MechanicalPistonBlockEntityclass — confirmed via bytecode inspection ofAllBlocks/AllBlockEntityTypes, both variants areBlockEntry<MechanicalPistonBlock>sharing one block-entity type. The sticky/regular distinction lives on the registeredBlockinstance (create:sticky_mechanical_pistonvs.create:mechanical_piston), not the block entity, soisSticky()reads it via Create's ownMechanicalPistonBlock.isStickyPiston(BlockState)helper rather than needing a second driver class.Exposed methods
All read-only except
gotoElevatorFloor:Create_ElevatorPulley:getPulleyDistance(),getElevatorFloor(),getElevatorFloors(),getElevatorFloorName(index),hasElevatorArrived(),gotoElevatorFloor(index)(mutating — moves the elevator, returns the change in target Y)Create_MechanicalBearing:getBearingAngle()Create_RopePulley:getPulleyDistance()Create_HosePulley:getPulleyDistance()Create_MechanicalPiston:getPistonDistance(),isSticky()Testing
Tested locally against NeoForge 1.21.1 + Create + a locally built
opencomputers-1.9.4-dev.localjar from this branch. Confirmed:gotoElevatorFloorcorrectly moves the elevator and returns the target-Y delta.isSticky()returnstrueon a sticky mechanical piston andfalseon a regular one, verified with both idle/retracted (Create swaps in a different block entity mid-animation, same as vanilla pistons, so idle state was required for a meaningful test).