проблема с гуи

Версия Minecraft
1.20.1
API
Fabric
Привет, пишу свое гуи и для настроек понадобилось создать виджет свича, в его render написал пока что только круг, запустил попробовать, но при заходе в гуи вылетает ошибка о делении на ноль, хотя в коде я нигде не делю и краш-лог вообще отсылает на super.render.

ModMainScreen:
package net.lil_requiem.gui;

import net.lil_requiem.gui.custom.Switch;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.Text;
import net.minecraft.util.Colors;
import net.minecraft.util.Identifier;

import java.util.HashMap;
import java.util.Map;

public class ModMainScreen extends Screen {
    //settings
    private boolean isBackgroundImage = true;
    //
    private int guiState = 1;
    private Identifier backgroundImage = new Identifier("textures/gui/background_night.png");
    private final Identifier ON = new Identifier("textures/gui/on.png");
    private final Identifier OFF = new Identifier("textures/gui/off.png");

    public ModMainScreen() {
        super(Text.of("Mod Main Screen"));
    }

    public ButtonWidget button1;
    public ButtonWidget button2;
    public ButtonWidget button3;
    private final Switch switch1 = new Switch((int) (width*0.90), (int) (height*0.15), (int) (width*0.05), (int) (height*0.05), Text.literal("Hello!"));

    @Override
    protected void init() {
        button1 = ButtonWidget.builder(Text.literal("SKILLS"), button -> {
                    guiState = 1;
                })
                .dimensions(width / 2 - 150, 5, 100, 20)
                .build();
        button2 = ButtonWidget.builder(Text.literal("TREE"), button -> {
                    guiState = 2;
                })
                .dimensions(width / 2 -50, 5, 100, 20)
                .build();
        button3 = ButtonWidget.builder(Text.literal("SETTINGS"), button -> {
                    guiState = 3;
                })
                .dimensions(width / 2 + 50, 5, 100, 20)
                .build();

        addDrawableChild(button1);
        addDrawableChild(button2);
        addDrawableChild(button3);
    }

    @Override
    public void render(DrawContext context, int mouseX, int mouseY, float delta) {
        super.render(context, mouseX, mouseY, delta);
        renderBackground(context);
        switch (guiState) {
            case 1:
                clearAndInit();
                renderfirst(context, mouseX, mouseY, delta);
                break;
            case 2:
                clearAndInit();
                rendersecond(context, mouseX, mouseY, delta);
                break;
            case 3:
                clearAndInit();
                renderthird(context, mouseX, mouseY, delta);
                break;
        }

    }

    private void renderfirst(DrawContext context, int mouseX, int mouseY, float delta){
        context.drawCenteredTextWithShadow(textRenderer, Text.literal("SKILLS"), width / 2, height / 2, 0xffffff);
    }
    private void rendersecond(DrawContext context, int mouseX, int mouseY, float delta){
        context.drawCenteredTextWithShadow(textRenderer, Text.literal("TREE"), width / 2, height / 2, 0xffffff);
    }
    private void renderthird(DrawContext context, int mouseX, int mouseY, float delta){
        context.drawTextWithShadow(textRenderer, "Background Image", (int) (width*0.05), (int) (height*0.15), 0xffffff);
        addDrawableChild(switch1);
    }
}

Switch:
package net.lil_requiem.gui.custom;

import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.widget.PressableWidget;
import net.minecraft.text.Text;

import static java.lang.Math.abs;
import static java.lang.Math.pow;

public class Switch extends PressableWidget {
    public static final int DEFAULT_WIDTH = 50;
    public static final int DEFAULT_HEIGHT = 20;
    public static final int DEFAULT_RADIUS = 20;
    public static int X = 0;
    public static int Y = 0;

    private boolean state;
    public Switch(int center_x, int center_y, int k, int l, Text text) {
        super(center_x, center_y, k, l, text);
        X=center_x;
        Y=center_y;
        state = false;
    }

    @Override
    public void onPress() {
        state = !state;
    }

    @Override
    public void render(DrawContext context, int mouseX, int mouseY, float delta) {
        super.render(context, mouseX, mouseY, delta);
        for(int i=X-DEFAULT_RADIUS; i<X+DEFAULT_RADIUS; i++) {
            for(int j=Y+DEFAULT_RADIUS; j>Y-DEFAULT_RADIUS; j--) {
                if(pow(abs(X-i), 2)+pow(abs(Y-j), 2)<pow(DEFAULT_RADIUS, 2)) {
                    if (state) context.fill(i, j, i, j, 0x009fff);
                    else context.fill(i, j, i, j, 0x009f40);
                }
            }
        }
    }

    @Override
    protected void appendClickableNarrations(NarrationMessageBuilder builder) {

    }
}
 
Краш-лог
---- Minecraft Crash Report ----
// Why did you do that?

Time: 2024-06-21 17:29:48
Description: Rendering screen

java.lang.ArithmeticException: / by zero
at java.base/java.lang.Math.floorDiv(Math.java:1472)
at net.minecraft.util.math.MathHelper.ceilDiv(MathHelper.java:730)
at net.minecraft.client.gui.DrawContext.createDivider(DrawContext.java:486)
at net.minecraft.client.gui.DrawContext.drawRepeatingTexture(DrawContext.java:469)
at net.minecraft.client.gui.DrawContext.drawNineSlicedTexture(DrawContext.java:460)
at net.minecraft.client.gui.DrawContext.drawNineSlicedTexture(DrawContext.java:424)
at net.minecraft.client.gui.widget.PressableWidget.renderButton(PressableWidget.java:33)
at net.minecraft.client.gui.widget.ClickableWidget.render(ClickableWidget.java:78)
at net.lil_requiem.gui.custom.Switch.render(Switch.java:33)
at net.minecraft.client.gui.screen.Screen.render(Screen.java:120)
at net.lil_requiem.gui.ModMainScreen.render(ModMainScreen.java:59)
at net.minecraft.client.gui.screen.Screen.renderWithTooltip(Screen.java:110)
at net.minecraft.client.render.GameRenderer.render(GameRenderer.java:945)
at net.minecraft.client.MinecraftClient.render(MinecraftClient.java:1219)
at net.minecraft.client.MinecraftClient.run(MinecraftClient.java:802)
at net.minecraft.client.main.Main.main(Main.java:250)
at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470)
at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
at net.fabricmc.devlaunchinjector.Main.main(Main.java:86)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Render thread
Stacktrace:
at java.base/java.lang.Math.floorDiv(Math.java:1472)
at net.minecraft.util.math.MathHelper.ceilDiv(MathHelper.java:730)
at net.minecraft.client.gui.DrawContext.createDivider(DrawContext.java:486)
at net.minecraft.client.gui.DrawContext.drawRepeatingTexture(DrawContext.java:469)
at net.minecraft.client.gui.DrawContext.drawNineSlicedTexture(DrawContext.java:460)
at net.minecraft.client.gui.DrawContext.drawNineSlicedTexture(DrawContext.java:424)
at net.minecraft.client.gui.widget.PressableWidget.renderButton(PressableWidget.java:33)
at net.minecraft.client.gui.widget.ClickableWidget.render(ClickableWidget.java:78)
at net.lil_requiem.gui.custom.Switch.render(Switch.java:33)
at net.minecraft.client.gui.screen.Screen.render(Screen.java:120)
at net.lil_requiem.gui.ModMainScreen.render(ModMainScreen.java:59)
at net.minecraft.client.gui.screen.Screen.renderWithTooltip(Screen.java:110)

-- Screen render details --
Details:
Screen name: net.lil_requiem.gui.ModMainScreen
Mouse location: Scaled: (387, 16). Absolute: (1163.000000, 49.000000)
Screen size: Scaled: (640, 360). Absolute: (1920, 1080). Scale factor of 3.000000
Stacktrace:
at net.minecraft.client.render.GameRenderer.render(GameRenderer.java:945)
at net.minecraft.client.MinecraftClient.render(MinecraftClient.java:1219)
at net.minecraft.client.MinecraftClient.run(MinecraftClient.java:802)
at net.minecraft.client.main.Main.main(Main.java:250)
at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470)
at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
at net.fabricmc.devlaunchinjector.Main.main(Main.java:86)

-- Affected level --
Details:
All players: 1 total; [ClientPlayerEntity['Player754'/134, l='ClientLevel', x=-179.46, y=71.00, z=-186.92]]
Chunk stats: 441, 249
Level dimension: minecraft:overworld
Level spawn location: World: (0,75,32), Section: (at 0,11,0 in 0,4,2; chunk contains blocks 0,-64,32 to 15,319,47), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,-64,0 to 511,319,511)
Level time: 13249 game time, 13249 day time
Server brand: fabric
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.world.ClientWorld.addDetailsToCrashReport(ClientWorld.java:458)
at net.minecraft.client.MinecraftClient.addDetailsToCrashReport(MinecraftClient.java:2406)
at net.minecraft.client.MinecraftClient.run(MinecraftClient.java:821)
at net.minecraft.client.main.Main.main(Main.java:250)
at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470)
at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
at net.fabricmc.devlaunchinjector.Main.main(Main.java:86)

-- Last reload --
Details:
Reload number: 1
Reload reason: initial
Finished: Yes
Packs: vanilla, fabric

-- System Details --
Details:
Minecraft Version: 1.20.1
Minecraft Version ID: 1.20.1
Operating System: Windows 11 (amd64) version 10.0
Java Version: 21.0.3, Amazon.com Inc.
Java VM Version: OpenJDK 64-Bit Server VM (mixed mode, sharing), Amazon.com Inc.
Memory: 550158040 bytes (524 MiB) / 1864368128 bytes (1778 MiB) up to 4276092928 bytes (4078 MiB)
CPUs: 12
Processor Vendor: AuthenticAMD
Processor Name: AMD Ryzen 5 2600 Six-Core Processor
Identifier: AuthenticAMD Family 23 Model 8 Stepping 2
Microarchitecture: Zen+
Frequency (GHz): 3.40
Number of physical packages: 1
Number of physical CPUs: 6
Number of logical CPUs: 12
Graphics card #0 name: AMD Radeon RX 6600 XT
Graphics card #0 vendor: Advanced Micro Devices, Inc. (0x1002)
Graphics card #0 VRAM (MB): 4095.00
Graphics card #0 deviceId: 0x73ff
Graphics card #0 versionInfo: DriverVersion=31.0.24033.1003
Memory slot #0 capacity (MB): 8192.00
Memory slot #0 clockSpeed (GHz): 2.40
Memory slot #0 type: DDR4
Memory slot #1 capacity (MB): 8192.00
Memory slot #1 clockSpeed (GHz): 2.40
Memory slot #1 type: DDR4
Virtual memory max (MB): 28085.40
Virtual memory used (MB): 19067.70
Swap memory total (MB): 11776.00
Swap memory used (MB): 160.36
JVM Flags: 0 total;
Fabric Mods:
fabric-api: Fabric API 0.92.0+1.20.1
fabric-api-base: Fabric API Base 0.4.31+1802ada577
fabric-api-lookup-api-v1: Fabric API Lookup API (v1) 1.6.36+1802ada577
fabric-biome-api-v1: Fabric Biome API (v1) 13.0.13+1802ada577
fabric-block-api-v1: Fabric Block API (v1) 1.0.11+1802ada577
fabric-block-view-api-v2: Fabric BlockView API (v2) 1.0.1+1802ada577
fabric-blockrenderlayer-v1: Fabric BlockRenderLayer Registration (v1) 1.1.41+1802ada577
fabric-client-tags-api-v1: Fabric Client Tags 1.1.2+1802ada577
fabric-command-api-v1: Fabric Command API (v1) 1.2.34+f71b366f77
fabric-command-api-v2: Fabric Command API (v2) 2.2.13+1802ada577
fabric-commands-v0: Fabric Commands (v0) 0.2.51+df3654b377
fabric-containers-v0: Fabric Containers (v0) 0.1.64+df3654b377
fabric-content-registries-v0: Fabric Content Registries (v0) 4.0.11+1802ada577
fabric-convention-tags-v1: Fabric Convention Tags 1.5.5+1802ada577
fabric-crash-report-info-v1: Fabric Crash Report Info (v1) 0.2.19+1802ada577
fabric-data-attachment-api-v1: Fabric Data Attachment API (v1) 1.0.0+de0fd6d177
fabric-data-generation-api-v1: Fabric Data Generation API (v1) 12.3.4+1802ada577
fabric-dimensions-v1: Fabric Dimensions API (v1) 2.1.54+1802ada577
fabric-entity-events-v1: Fabric Entity Events (v1) 1.6.0+1c78457f77
fabric-events-interaction-v0: Fabric Events Interaction (v0) 0.6.2+1802ada577
fabric-events-lifecycle-v0: Fabric Events Lifecycle (v0) 0.2.63+df3654b377
fabric-game-rule-api-v1: Fabric Game Rule API (v1) 1.0.40+1802ada577
fabric-gametest-api-v1: Fabric Game Test API (v1) 1.2.13+1802ada577
fabric-item-api-v1: Fabric Item API (v1) 2.1.28+1802ada577
fabric-item-group-api-v1: Fabric Item Group API (v1) 4.0.12+1802ada577
fabric-key-binding-api-v1: Fabric Key Binding API (v1) 1.0.37+1802ada577
fabric-keybindings-v0: Fabric Key Bindings (v0) 0.2.35+df3654b377
fabric-lifecycle-events-v1: Fabric Lifecycle Events (v1) 2.2.22+1802ada577
fabric-loot-api-v2: Fabric Loot API (v2) 1.2.1+1802ada577
fabric-loot-tables-v1: Fabric Loot Tables (v1) 1.1.45+9e7660c677
fabric-message-api-v1: Fabric Message API (v1) 5.1.9+1802ada577
fabric-mining-level-api-v1: Fabric Mining Level API (v1) 2.1.50+1802ada577
fabric-model-loading-api-v1: Fabric Model Loading API (v1) 1.0.3+1802ada577
fabric-models-v0: Fabric Models (v0) 0.4.2+9386d8a777
fabric-networking-api-v1: Fabric Networking API (v1) 1.3.11+1802ada577
fabric-networking-v0: Fabric Networking (v0) 0.3.51+df3654b377
fabric-object-builder-api-v1: Fabric Object Builder API (v1) 11.1.3+1802ada577
fabric-particles-v1: Fabric Particles (v1) 1.1.2+1802ada577
fabric-recipe-api-v1: Fabric Recipe API (v1) 1.0.21+1802ada577
fabric-registry-sync-v0: Fabric Registry Sync (v0) 2.3.3+1802ada577
fabric-renderer-api-v1: Fabric Renderer API (v1) 3.2.1+1802ada577
fabric-renderer-indigo: Fabric Renderer - Indigo 1.5.1+1802ada577
fabric-renderer-registries-v1: Fabric Renderer Registries (v1) 3.2.46+df3654b377
fabric-rendering-data-attachment-v1: Fabric Rendering Data Attachment (v1) 0.3.37+92a0d36777
fabric-rendering-fluids-v1: Fabric Rendering Fluids (v1) 3.0.28+1802ada577
fabric-rendering-v0: Fabric Rendering (v0) 1.1.49+df3654b377
fabric-rendering-v1: Fabric Rendering (v1) 3.0.8+1802ada577
fabric-resource-conditions-api-v1: Fabric Resource Conditions API (v1) 2.3.8+1802ada577
fabric-resource-loader-v0: Fabric Resource Loader (v0) 0.11.10+1802ada577
fabric-screen-api-v1: Fabric Screen API (v1) 2.0.8+1802ada577
fabric-screen-handler-api-v1: Fabric Screen Handler API (v1) 1.3.30+1802ada577
fabric-sound-api-v1: Fabric Sound API (v1) 1.0.13+1802ada577
fabric-transfer-api-v1: Fabric Transfer API (v1) 3.3.4+1802ada577
fabric-transitive-access-wideners-v1: Fabric Transitive Access Wideners (v1) 4.3.1+1802ada577
fabricloader: Fabric Loader 0.15.7
geckolib: GeckoLib 4 4.4.3
java: OpenJDK 64-Bit Server VM 21
minecraft: Minecraft 1.20.1
mixinextras: MixinExtras 0.3.5
rpserver-fighting: RPServer-Fighting 1.0.0
Launched Version: Fabric
Backend library: LWJGL version 3.3.2-snapshot
Backend API: AMD Radeon RX 6600 XT GL version 3.2.0 Core Profile Context 24.5.1.240502, ATI Technologies Inc.
Window size: 1920x1080
GL Caps: Using framebuffer using OpenGL 3.2
GL debug messages:
Using VBOs: Yes
Is Modded: Definitely; Client brand changed to 'fabric'; Server brand changed to 'fabric'
Type: Integrated Server (map_client.txt)
Graphics mode: fancy
Resource Packs: fabric
Current Language: en_us
CPU: 12x AMD Ryzen 5 2600 Six-Core Processor
Server Running: true
Player Count: 1 / 8; [ServerPlayerEntity['Player754'/134, l='ServerLevel[New World]', x=-179.46, y=71.00, z=-186.92]]
Data Packs: vanilla, fabric
Enabled Feature Flags: minecraft:vanilla
World Generation: Stable
Краш-лог:
---- Minecraft Crash Report ----
// Why did you do that?

Time: 2024-06-21 17:29:48
Description: Rendering screen

java.lang.ArithmeticException: / by zero
	at java.base/java.lang.Math.floorDiv(Math.java:1472)
	at net.minecraft.util.math.MathHelper.ceilDiv(MathHelper.java:730)
	at net.minecraft.client.gui.DrawContext.createDivider(DrawContext.java:486)
	at net.minecraft.client.gui.DrawContext.drawRepeatingTexture(DrawContext.java:469)
	at net.minecraft.client.gui.DrawContext.drawNineSlicedTexture(DrawContext.java:460)
	at net.minecraft.client.gui.DrawContext.drawNineSlicedTexture(DrawContext.java:424)
	at net.minecraft.client.gui.widget.PressableWidget.renderButton(PressableWidget.java:33)
	at net.minecraft.client.gui.widget.ClickableWidget.render(ClickableWidget.java:78)
	at net.lil_requiem.gui.custom.Switch.render(Switch.java:33)
	at net.minecraft.client.gui.screen.Screen.render(Screen.java:120)
	at net.lil_requiem.gui.ModMainScreen.render(ModMainScreen.java:59)
	at net.minecraft.client.gui.screen.Screen.renderWithTooltip(Screen.java:110)
	at net.minecraft.client.render.GameRenderer.render(GameRenderer.java:945)
	at net.minecraft.client.MinecraftClient.render(MinecraftClient.java:1219)
	at net.minecraft.client.MinecraftClient.run(MinecraftClient.java:802)
	at net.minecraft.client.main.Main.main(Main.java:250)
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470)
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
	at net.fabricmc.devlaunchinjector.Main.main(Main.java:86)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Render thread
Stacktrace:
	at java.base/java.lang.Math.floorDiv(Math.java:1472)
	at net.minecraft.util.math.MathHelper.ceilDiv(MathHelper.java:730)
	at net.minecraft.client.gui.DrawContext.createDivider(DrawContext.java:486)
	at net.minecraft.client.gui.DrawContext.drawRepeatingTexture(DrawContext.java:469)
	at net.minecraft.client.gui.DrawContext.drawNineSlicedTexture(DrawContext.java:460)
	at net.minecraft.client.gui.DrawContext.drawNineSlicedTexture(DrawContext.java:424)
	at net.minecraft.client.gui.widget.PressableWidget.renderButton(PressableWidget.java:33)
	at net.minecraft.client.gui.widget.ClickableWidget.render(ClickableWidget.java:78)
	at net.lil_requiem.gui.custom.Switch.render(Switch.java:33)
	at net.minecraft.client.gui.screen.Screen.render(Screen.java:120)
	at net.lil_requiem.gui.ModMainScreen.render(ModMainScreen.java:59)
	at net.minecraft.client.gui.screen.Screen.renderWithTooltip(Screen.java:110)

-- Screen render details --
Details:
	Screen name: net.lil_requiem.gui.ModMainScreen
	Mouse location: Scaled: (387, 16). Absolute: (1163.000000, 49.000000)
	Screen size: Scaled: (640, 360). Absolute: (1920, 1080). Scale factor of 3.000000
Stacktrace:
	at net.minecraft.client.render.GameRenderer.render(GameRenderer.java:945)
	at net.minecraft.client.MinecraftClient.render(MinecraftClient.java:1219)
	at net.minecraft.client.MinecraftClient.run(MinecraftClient.java:802)
	at net.minecraft.client.main.Main.main(Main.java:250)
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470)
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
	at net.fabricmc.devlaunchinjector.Main.main(Main.java:86)

-- Affected level --
Details:
	All players: 1 total; [ClientPlayerEntity['Player754'/134, l='ClientLevel', x=-179.46, y=71.00, z=-186.92]]
	Chunk stats: 441, 249
	Level dimension: minecraft:overworld
	Level spawn location: World: (0,75,32), Section: (at 0,11,0 in 0,4,2; chunk contains blocks 0,-64,32 to 15,319,47), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,-64,0 to 511,319,511)
	Level time: 13249 game time, 13249 day time
	Server brand: fabric
	Server type: Integrated singleplayer server
Stacktrace:
	at net.minecraft.client.world.ClientWorld.addDetailsToCrashReport(ClientWorld.java:458)
	at net.minecraft.client.MinecraftClient.addDetailsToCrashReport(MinecraftClient.java:2406)
	at net.minecraft.client.MinecraftClient.run(MinecraftClient.java:821)
	at net.minecraft.client.main.Main.main(Main.java:250)
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470)
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
	at net.fabricmc.devlaunchinjector.Main.main(Main.java:86)

-- Last reload --
Details:
	Reload number: 1
	Reload reason: initial
	Finished: Yes
	Packs: vanilla, fabric

-- System Details --
Details:
	Minecraft Version: 1.20.1
	Minecraft Version ID: 1.20.1
	Operating System: Windows 11 (amd64) version 10.0
	Java Version: 21.0.3, Amazon.com Inc.
	Java VM Version: OpenJDK 64-Bit Server VM (mixed mode, sharing), Amazon.com Inc.
	Memory: 550158040 bytes (524 MiB) / 1864368128 bytes (1778 MiB) up to 4276092928 bytes (4078 MiB)
	CPUs: 12
	Processor Vendor: AuthenticAMD
	Processor Name: AMD Ryzen 5 2600 Six-Core Processor            
	Identifier: AuthenticAMD Family 23 Model 8 Stepping 2
	Microarchitecture: Zen+
	Frequency (GHz): 3.40
	Number of physical packages: 1
	Number of physical CPUs: 6
	Number of logical CPUs: 12
	Graphics card #0 name: AMD Radeon RX 6600 XT
	Graphics card #0 vendor: Advanced Micro Devices, Inc. (0x1002)
	Graphics card #0 VRAM (MB): 4095.00
	Graphics card #0 deviceId: 0x73ff
	Graphics card #0 versionInfo: DriverVersion=31.0.24033.1003
	Memory slot #0 capacity (MB): 8192.00
	Memory slot #0 clockSpeed (GHz): 2.40
	Memory slot #0 type: DDR4
	Memory slot #1 capacity (MB): 8192.00
	Memory slot #1 clockSpeed (GHz): 2.40
	Memory slot #1 type: DDR4
	Virtual memory max (MB): 28085.40
	Virtual memory used (MB): 19067.70
	Swap memory total (MB): 11776.00
	Swap memory used (MB): 160.36
	JVM Flags: 0 total; 
	Fabric Mods: 
		fabric-api: Fabric API 0.92.0+1.20.1
		fabric-api-base: Fabric API Base 0.4.31+1802ada577
		fabric-api-lookup-api-v1: Fabric API Lookup API (v1) 1.6.36+1802ada577
		fabric-biome-api-v1: Fabric Biome API (v1) 13.0.13+1802ada577
		fabric-block-api-v1: Fabric Block API (v1) 1.0.11+1802ada577
		fabric-block-view-api-v2: Fabric BlockView API (v2) 1.0.1+1802ada577
		fabric-blockrenderlayer-v1: Fabric BlockRenderLayer Registration (v1) 1.1.41+1802ada577
		fabric-client-tags-api-v1: Fabric Client Tags 1.1.2+1802ada577
		fabric-command-api-v1: Fabric Command API (v1) 1.2.34+f71b366f77
		fabric-command-api-v2: Fabric Command API (v2) 2.2.13+1802ada577
		fabric-commands-v0: Fabric Commands (v0) 0.2.51+df3654b377
		fabric-containers-v0: Fabric Containers (v0) 0.1.64+df3654b377
		fabric-content-registries-v0: Fabric Content Registries (v0) 4.0.11+1802ada577
		fabric-convention-tags-v1: Fabric Convention Tags 1.5.5+1802ada577
		fabric-crash-report-info-v1: Fabric Crash Report Info (v1) 0.2.19+1802ada577
		fabric-data-attachment-api-v1: Fabric Data Attachment API (v1) 1.0.0+de0fd6d177
		fabric-data-generation-api-v1: Fabric Data Generation API (v1) 12.3.4+1802ada577
		fabric-dimensions-v1: Fabric Dimensions API (v1) 2.1.54+1802ada577
		fabric-entity-events-v1: Fabric Entity Events (v1) 1.6.0+1c78457f77
		fabric-events-interaction-v0: Fabric Events Interaction (v0) 0.6.2+1802ada577
		fabric-events-lifecycle-v0: Fabric Events Lifecycle (v0) 0.2.63+df3654b377
		fabric-game-rule-api-v1: Fabric Game Rule API (v1) 1.0.40+1802ada577
		fabric-gametest-api-v1: Fabric Game Test API (v1) 1.2.13+1802ada577
		fabric-item-api-v1: Fabric Item API (v1) 2.1.28+1802ada577
		fabric-item-group-api-v1: Fabric Item Group API (v1) 4.0.12+1802ada577
		fabric-key-binding-api-v1: Fabric Key Binding API (v1) 1.0.37+1802ada577
		fabric-keybindings-v0: Fabric Key Bindings (v0) 0.2.35+df3654b377
		fabric-lifecycle-events-v1: Fabric Lifecycle Events (v1) 2.2.22+1802ada577
		fabric-loot-api-v2: Fabric Loot API (v2) 1.2.1+1802ada577
		fabric-loot-tables-v1: Fabric Loot Tables (v1) 1.1.45+9e7660c677
		fabric-message-api-v1: Fabric Message API (v1) 5.1.9+1802ada577
		fabric-mining-level-api-v1: Fabric Mining Level API (v1) 2.1.50+1802ada577
		fabric-model-loading-api-v1: Fabric Model Loading API (v1) 1.0.3+1802ada577
		fabric-models-v0: Fabric Models (v0) 0.4.2+9386d8a777
		fabric-networking-api-v1: Fabric Networking API (v1) 1.3.11+1802ada577
		fabric-networking-v0: Fabric Networking (v0) 0.3.51+df3654b377
		fabric-object-builder-api-v1: Fabric Object Builder API (v1) 11.1.3+1802ada577
		fabric-particles-v1: Fabric Particles (v1) 1.1.2+1802ada577
		fabric-recipe-api-v1: Fabric Recipe API (v1) 1.0.21+1802ada577
		fabric-registry-sync-v0: Fabric Registry Sync (v0) 2.3.3+1802ada577
		fabric-renderer-api-v1: Fabric Renderer API (v1) 3.2.1+1802ada577
		fabric-renderer-indigo: Fabric Renderer - Indigo 1.5.1+1802ada577
		fabric-renderer-registries-v1: Fabric Renderer Registries (v1) 3.2.46+df3654b377
		fabric-rendering-data-attachment-v1: Fabric Rendering Data Attachment (v1) 0.3.37+92a0d36777
		fabric-rendering-fluids-v1: Fabric Rendering Fluids (v1) 3.0.28+1802ada577
		fabric-rendering-v0: Fabric Rendering (v0) 1.1.49+df3654b377
		fabric-rendering-v1: Fabric Rendering (v1) 3.0.8+1802ada577
		fabric-resource-conditions-api-v1: Fabric Resource Conditions API (v1) 2.3.8+1802ada577
		fabric-resource-loader-v0: Fabric Resource Loader (v0) 0.11.10+1802ada577
		fabric-screen-api-v1: Fabric Screen API (v1) 2.0.8+1802ada577
		fabric-screen-handler-api-v1: Fabric Screen Handler API (v1) 1.3.30+1802ada577
		fabric-sound-api-v1: Fabric Sound API (v1) 1.0.13+1802ada577
		fabric-transfer-api-v1: Fabric Transfer API (v1) 3.3.4+1802ada577
		fabric-transitive-access-wideners-v1: Fabric Transitive Access Wideners (v1) 4.3.1+1802ada577
		fabricloader: Fabric Loader 0.15.7
		geckolib: GeckoLib 4 4.4.3
		java: OpenJDK 64-Bit Server VM 21
		minecraft: Minecraft 1.20.1
		mixinextras: MixinExtras 0.3.5
		rpserver-fighting: RPServer-Fighting 1.0.0
	Launched Version: Fabric
	Backend library: LWJGL version 3.3.2-snapshot
	Backend API: AMD Radeon RX 6600 XT GL version 3.2.0 Core Profile Context 24.5.1.240502, ATI Technologies Inc.
	Window size: 1920x1080
	GL Caps: Using framebuffer using OpenGL 3.2
	GL debug messages: 
	Using VBOs: Yes
	Is Modded: Definitely; Client brand changed to 'fabric'; Server brand changed to 'fabric'
	Type: Integrated Server (map_client.txt)
	Graphics mode: fancy
	Resource Packs: fabric
	Current Language: en_us
	CPU: 12x AMD Ryzen 5 2600 Six-Core Processor 
	Server Running: true
	Player Count: 1 / 8; [ServerPlayerEntity['Player754'/134, l='ServerLevel[New World]', x=-179.46, y=71.00, z=-186.92]]
	Data Packs: vanilla, fabric
	Enabled Feature Flags: minecraft:vanilla
	World Generation: Stable
pic
 
1) Зачем ты в квадрат возводишь модуль? Не пофиг ли, если число одно и то же будет? Напомню: pow достаточно дорогая операция из-за особенностей своей реализации (это касается и C++, и Java в т.ч.), так что в случае куба или квадрата лучше просто перемножать число на себя: (X-i) * (X-i).
2) Рассматривай случай i = j = 0, тогда ошибок быть не должно.
 
окей, я сделал все, как ты сказал. Для того, что бы не делать 4 раза разность, я сделал 2 переменные. так же рассмотрел случай, если i==j==0, майн все равно крашит с той же ошибкой деления на ноль.

render:
@Override
    public void render(DrawContext context, int mouseX, int mouseY, float delta) {
        super.render(context, mouseX, mouseY, delta);
        for(int i=X-DEFAULT_RADIUS; i<X+DEFAULT_RADIUS; i++) {
            for(int j=Y+DEFAULT_RADIUS; j>Y-DEFAULT_RADIUS; j--) {
                if (i!=0 && j!=0) {
                    int a, b;
                    a = X-i;
                    b = Y-j;
                    if((a*a)+(b*b)<(DEFAULT_RADIUS*DEFAULT_RADIUS)) {
                        if (state) context.fill(i, j, i, j, 0x009fff);
                        else context.fill(i, j, i, j,0x009f40);
                    }
                }
            }
        }
    }
Если честно я не особо понял, зачем проверять условие с равностью нуля и i, j, потому что деления с участием этих переменных нет и не было.
 
Последнее редактирование:
Вообще ничего не нашел, все сводится к Math.fma(), в котором деления так же нет.

Math.fma():
@IntrinsicCandidate
    public static float fma(float a, float b, float c) {
        if (Float.isFinite(a) && Float.isFinite(b) && Float.isFinite(c)) {
            if (a == 0.0 || b == 0.0) {
                return a * b + c; // Handled signed zero cases
            } else {
                return (new BigDecimal((double)a * (double)b) // Exact multiply
                        .add(new BigDecimal((double)c)))      // Exact sum
                    .floatValue();                            // One rounding
                                                              // to a float value
            }
        } else {
            // At least one of a,b, and c is non-finite. The result
            // will be non-finite as well and will be the same
            // non-finite value under double as float arithmetic.
            return (float)fma((double)a, (double)b, (double)c);
        }
    }
 
так, я походил по краш логу и понял, что дело в private final Switch switch1 = new Switch((int) (width*0.90), (int) (height*0.15), (int) (width*0.05), (int) (height*0.05), Text.literal("Hello!"));. посчитал эти значения в калькуляторе и заменил их на private final Switch switch1 = new Switch(1728, 162, 96, 52, Text.literal("Hello!")); . Теперь майн не вылетает, но и сам круг не рисуется, можете подсказать, что не так с рисовкой?
 
Смотри в DrawContext#createDivider. Где-то там у тебя возникает деление на 0. В частности, обрати внимание на MathHelper#ceilDiv (который ссылается на floorDiv; в последнем на 2 параметр приходит 0 => возникает деление на 0).
Среды на Fabric 1.20.1 у меня нет, а на Forge 1.20.1 такого класса (DrawContext) нет, потому подсказать могу лишь немного.
 
Назад
Сверху