diff --git a/src/main/java/io/github/cadiboo/nocubes/client/ClientEventSubscriber.java b/src/main/java/io/github/cadiboo/nocubes/client/ClientEventSubscriber.java index bbb10de6..90de2937 100644 --- a/src/main/java/io/github/cadiboo/nocubes/client/ClientEventSubscriber.java +++ b/src/main/java/io/github/cadiboo/nocubes/client/ClientEventSubscriber.java @@ -51,7 +51,7 @@ public static void onClientJoinServer(ClientPlayerNetworkEvent.LoggingIn event) if (!NoCubesNetwork.currentServerHasNoCubes) { // This lets players not phase through the ground on servers that don't have NoCubes installed NoCubesConfig.Server.collisionsEnabled = false; - ClientUtil.warnPlayer(NoCubes.MOD_ID + ".notification.notInstalledOnServer", KeyMappings.translate(KeyMappings.TOGGLE_SMOOTHABLE)); + ClientUtil.warnPlayer(NoCubes.MOD_ID + ".notification.notInstalledOnServer", KeyMappings.translate(KeyMappings.TOGGLE_SMOOTHABLE_BLOCK_TYPE)); } } diff --git a/src/main/java/io/github/cadiboo/nocubes/client/ClientUtil.java b/src/main/java/io/github/cadiboo/nocubes/client/ClientUtil.java index 309c7637..b954525f 100644 --- a/src/main/java/io/github/cadiboo/nocubes/client/ClientUtil.java +++ b/src/main/java/io/github/cadiboo/nocubes/client/ClientUtil.java @@ -41,7 +41,7 @@ public static void sendPlayerInfoMessage() { if (NoCubesConfig.Client.infoMessage) Minecraft.getInstance().player.sendSystemMessage( Component.translatable(NoCubes.MOD_ID + ".notification.infoMessage", - KeyMappings.translate(KeyMappings.TOGGLE_SMOOTHABLE), + KeyMappings.translate(KeyMappings.TOGGLE_SMOOTHABLE_BLOCK_TYPE), NoCubesConfig.Client.INFO_MESSAGE, clientConfigComponent() ).withStyle(ChatFormatting.GREEN)); diff --git a/src/main/java/io/github/cadiboo/nocubes/client/KeyMappings.java b/src/main/java/io/github/cadiboo/nocubes/client/KeyMappings.java index 228be8de..56e4983a 100644 --- a/src/main/java/io/github/cadiboo/nocubes/client/KeyMappings.java +++ b/src/main/java/io/github/cadiboo/nocubes/client/KeyMappings.java @@ -31,13 +31,21 @@ public final class KeyMappings { private static final Logger LOG = LogManager.getLogger(); public static final String TOGGLE_VISUALS = "toggleVisuals"; - public static final String TOGGLE_SMOOTHABLE = "toggleSmoothable"; + /** + * It is tedious to have to add/remove each block state for blocks that have many states with little to no visual difference. + * Leaves are a primary example of this. + * Therefore, the default add/remove keybind changes all block states for the targeted block. + * We have {@link #TOGGLE_SMOOTHABLE_BLOCK_STATE a separate keybind} that only changes a single state to give players that want it more fine-grained control. + */ + public static final String TOGGLE_SMOOTHABLE_BLOCK_TYPE = "toggleSmoothable"; + public static final String TOGGLE_SMOOTHABLE_BLOCK_STATE = "toggleSmoothableBlockState"; public static void register(RegisterKeyMappingsEvent registerEvent, IEventBus forgeBus) { LOG.debug("Registering keybindings"); var keybindings = Lists.newArrayList( makeKeybinding(registerEvent, TOGGLE_VISUALS, InputConstants.UNKNOWN.getValue(), KeyMappings::toggleVisuals), - makeKeybinding(registerEvent, TOGGLE_SMOOTHABLE, GLFW.GLFW_KEY_N, KeyMappings::toggleLookedAtSmoothable) + makeKeybinding(registerEvent, TOGGLE_SMOOTHABLE_BLOCK_TYPE, GLFW.GLFW_KEY_N, () -> toggleLookedAtSmoothable(true)), + makeKeybinding(registerEvent, TOGGLE_SMOOTHABLE_BLOCK_STATE, InputConstants.UNKNOWN.getValue(), () -> toggleLookedAtSmoothable(false)) ); forgeBus.addListener((TickEvent.ClientTickEvent tickEvent) -> { if (tickEvent.phase != TickEvent.Phase.END) @@ -75,7 +83,7 @@ private static void toggleVisuals() { reloadAllChunks("toggleVisuals was pressed"); } - private static void toggleLookedAtSmoothable() { + private static void toggleLookedAtSmoothable(boolean changeAllStatesOfBlock) { var minecraft = Minecraft.getInstance(); var world = minecraft.level; var player = minecraft.player; @@ -88,10 +96,7 @@ private static void toggleLookedAtSmoothable() { var targeted = ((BlockHitResult) lookingAt); var targetedState = world.getBlockState(targeted.getBlockPos()); var newValue = !NoCubes.smoothableHandler.isSmoothable(targetedState); - // Add all states if the player is not crouching (to make it easy to toggle on/off all leaves) - // If the player needs fine-grained control over which specific blockstates are smoothable they can crouch - // (Yes I know it says shift, it actually checks the crouch key) - var states = player.isShiftKeyDown() ? new BlockState[]{targetedState} : ModUtil.getStates(targetedState.getBlock()).toArray(BlockState[]::new); + var states = changeAllStatesOfBlock ? ModUtil.getStates(targetedState.getBlock()).toArray(BlockState[]::new) : new BlockState[] {targetedState}; LOG.debug("toggleLookedAtSmoothable currentServerHasNoCubes={}", NoCubesNetwork.currentServerHasNoCubes); if (!NoCubesNetwork.currentServerHasNoCubes) { diff --git a/src/main/resources/assets/nocubes/lang/en_us.json b/src/main/resources/assets/nocubes/lang/en_us.json index 7e255b34..9a1e54b6 100644 --- a/src/main/resources/assets/nocubes/lang/en_us.json +++ b/src/main/resources/assets/nocubes/lang/en_us.json @@ -1,7 +1,8 @@ { "nocubes.keycategory": "NoCubes", "nocubes.key.toggleVisuals": "Toggle rendering", - "nocubes.key.toggleSmoothable": "Toggle block smoothness", + "nocubes.key.toggleSmoothableBlockType": "Toggle block smoothness", + "nocubes.key.toggleSmoothableBlockState": "Toggle specific block state smoothness", "nocubes.config.infoMessage": "NoCubes info message", "nocubes.config.render": "NoCubes rendering",