fix: re-add switching to eraser when using pencil tool with air block

This commit is contained in:
trafficlunar 2025-02-07 17:18:25 +00:00
parent 58c30b22bf
commit e5aaf1486c
2 changed files with 9 additions and 6 deletions

View file

@ -45,7 +45,7 @@ function Canvas() {
const { settings } = useContext(SettingsContext);
const { missingTexture } = useContext(TexturesContext);
const { isDark } = useContext(ThemeContext);
const { tool, radius, setTool } = useContext(ToolContext);
const { tool, radius, selectedBlock, setTool } = useContext(ToolContext);
const textures = useTextures(version);
const blockData = useBlockData(version);
@ -125,8 +125,14 @@ function Canvas() {
eraser: eraserTool,
};
// Switch to eraser tool if selected block is air when using pencil
if (tool === "pencil" && selectedBlock === "air") {
eraserTool.use();
return;
}
tools[tool]?.use();
}, [tool, moveTool, lassoTool, pencilTool, eraserTool, rectangleSelectTool]);
}, [tool, selectedBlock, moveTool, lassoTool, pencilTool, eraserTool, rectangleSelectTool]);
const onMouseMove = useCallback(
(e: React.MouseEvent) => {

View file

@ -14,10 +14,7 @@ export function usePencilTool(mouseCoords: Position) {
const radiusPosition = useRadiusPosition(mouseCoords);
const use = () => {
// if (selectedBlock == "air") {
// eraseTool();
// break;
// }
if (selectedBlock == "air") return;
const radiusBlocks: Block[] = [];
for (let x = 0; x < radius; x++) {