[SPIGOT-6205] Switch$Face casted to FaceAttachable$AttachedFace Created: 28/Oct/20  Updated: 03/Nov/20  Resolved: 03/Nov/20

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Mariell Hoversholm Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: bug, event

Version: git-Spigot-988b411-055870c (MC: 1.16.3) (been around since at least 1.15.2, though)
Plugin: CoreProtect (although irrelevant)
Guidelines Read: Yes

 Description   

If one first accessed e.g. a wooden button as a `Switch` to get its `Switch.Face` (`Switch#getFace`), it starts throwing a `ClassCastException` if you want to access it as a `FaceAttachable` for its `FaceAttachable.AttachedFace` (`FaceAttachable#getAttachedFace`).

 

The issue is with `CraftBlockData#toBukkit` caching "incorrect" types into its `classMappings` map, as `BlockStateEnum` called `"face"` can be mapped to both `Switch.Face` and `FaceAttachable.AttachedFace`. The `BlockStateEnum` is found in `CraftSwitch` and `CraftFaceAttachable`.



 Comments   
Comment by Mariell Hoversholm [ 28/Oct/20 ]

I've signed the CLA; I'll open a PR.

Comment by md_5 [ 28/Oct/20 ]

My bad, though getFace is deprecated.

We cannot pull code that is not pull requested to Spigot irrespective of MIT licensing.

Comment by Mariell Hoversholm [ 28/Oct/20 ]

`Switch#getFace`, not `#getFacing`.

Comment by Mariell Hoversholm [ 28/Oct/20 ]

I can't close and whatever, so I don't really care.

I patched this in this PR to Paper: https://github.com/PaperMC/Paper/pull/4701

The patch is MIT licensed, so you're free to pull it into CraftBukkit/Spigot.

Comment by Mariell Hoversholm [ 28/Oct/20 ]

First issue was not the charm. Will try to close & reopen under Spigot project.

Generated at Tue Apr 22 03:57:08 UTC 2025 using Jira 10.3.5#10030005-sha1:190c783f2bd6c69cd5accdb70f97e48812a78d14.