Added MossyCarpet to MaterialSides#2808
Conversation
| return (data instanceof Wall | ||
| || data instanceof RedstoneWire | ||
| || (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21) && data instanceof MossyCarpet)); |
There was a problem hiding this comment.
Is the bracket wrapping all of this not redundant?
| list.add(carpet.getHeight(BlockFace.EAST).name()); | ||
| list.add(carpet.getHeight(BlockFace.SOUTH).name()); | ||
| list.add(carpet.getHeight(BlockFace.WEST).name()); | ||
| list.add(carpet.isBottom() ? "TRUE" : "FALSE"); |
There was a problem hiding this comment.
Is true/false the best option here? Following the precedent from Wall I'd imagine something like BOTTOM/NONE imo
| mechanism.echoError("Invalid sides list, size must be 5."); | ||
| return; | ||
| } | ||
| wall.setHeight(BlockFace.NORTH, Wall.Height.valueOf(list.get(0).toUpperCase())); |
There was a problem hiding this comment.
Would be nice to update this as well, even just CoreUtilities#toUpperCase/equalsIgnoreCase would be good, but if you wanna update it more can make a util method for this and use ElementTag#asEnum (probably the static one) with a cleaner error message.
| setSide(wall::setHeight, Wall.Height.class, BlockFace.EAST, list, 1, mechanism); | ||
| setSide(wall::setHeight, Wall.Height.class, BlockFace.SOUTH, list, 2, mechanism); | ||
| setSide(wall::setHeight, Wall.Height.class, BlockFace.WEST, list, 3, mechanism); | ||
| wall.setUp(list.get(4).equalsIgnoreCase("tall")); |
There was a problem hiding this comment.
Nitpick, but these can be CoreUtilities#equalsIgnoreCase/#toLowerCase on the list value + a normal equals
| public static <T> void setSide(BiConsumer<BlockFace, T> consumer, Class<T> type, BlockFace face, ListTag list, int index, Mechanism mechanism) { | ||
| T value = Utilities.elementToEnumlike(new ElementTag(list.get(index)), type); |
There was a problem hiding this comment.
Looks good overall, but you'd want T as a T extends Enum<T>, to only allow enum types.
That'll then let you just use ElementTag#asEnum (probably the static one for this?) instead of the Utilities conversion methods.
| public static <T> void setSide(BiConsumer<BlockFace, T> consumer, Class<T> type, BlockFace face, ListTag list, int index, Mechanism mechanism) { | ||
| T value = Utilities.elementToEnumlike(new ElementTag(list.get(index)), type); | ||
| if (value == null) { | ||
| mechanism.echoError("'"+ list.get(index) + "' is not a valid " + DebugInternals.getClassNameOpti(type) + "."); |
| // @returns ListTag | ||
| // @mechanism MaterialTag.heights | ||
| // @group properties | ||
| // @deprecated Use 'sides' |
Requested in https://discord.com/channels/315163488085475337/1455274906085494817, adds pale mossy carpet to the MaterialSides property to control the height of each side, and whether the bottom is shown or not.
Property also modernized as well.