• Ищем качественного (не новичок) разработчиков Xenforo для этого форума! В идеале, чтобы ты был фулл стек программистом. Если у тебя есть что показать, то свяжись с нами по контактным данным: https://t.me/DREDD

Вопрос Краш и баг с инвентарём

неактуально
 
Начинающий
Начинающий
Статус
Оффлайн
Регистрация
13 Май 2025
Сообщения
71
Реакции
1
инвентарь забагался
Пожалуйста, авторизуйтесь для просмотра ссылки.

Java:
Expand Collapse Copy
// Don't be sad, have a hug! <3



Time: 31.05.2025, 14:45

Description: Rendering screen



java.lang.ExceptionInInitializerError

    at net.minecraft.client.gui.screen.inventory.CreativeScreen.drawGuiContainerBackgroundLayer(CreativeScreen.java:833)

    at net.minecraft.client.gui.screen.inventory.ContainerScreen.render(ContainerScreen.java:134)

    at net.minecraft.client.gui.DisplayEffectsScreen.render(DisplayEffectsScreen.java:50)

    at net.minecraft.client.gui.screen.inventory.CreativeScreen.render(CreativeScreen.java:763)

    at net.minecraft.client.renderer.GameRenderer.updateCameraAndRender(GameRenderer.java:783)

    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:971)

    at net.minecraft.client.Minecraft.run(Minecraft.java:564)

    at net.minecraft.client.main.Main.main(Main.java:186)

    at Start.main(Start.java:11)

Caused by: java.lang.SecurityException: class "dfo"'s signer information does not match signer information of other classes in the same package

    at java.base/java.lang.ClassLoader.checkCerts(ClassLoader.java:1163)

    at java.base/java.lang.ClassLoader.preDefineClass(ClassLoader.java:907)

    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1015)

    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)

    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)

    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)

    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)

    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)

    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)

    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)

    at com.mojang.blaze3d.systems.RenderSystem.<clinit>(SourceFile:34)

    ... 9 more





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

---------------------------------------------------------------------------------------



-- Head --

Thread: Render thread

Stacktrace:

    at net.minecraft.client.gui.screen.inventory.CreativeScreen.drawGuiContainerBackgroundLayer(CreativeScreen.java:833)

    at net.minecraft.client.gui.screen.inventory.ContainerScreen.render(ContainerScreen.java:134)

    at net.minecraft.client.gui.DisplayEffectsScreen.render(DisplayEffectsScreen.java:50)

    at net.minecraft.client.gui.screen.inventory.CreativeScreen.render(CreativeScreen.java:763)



-- Screen render details --

Details:

    Screen name: net.minecraft.client.gui.screen.inventory.CreativeScreen

    Mouse location: Scaled: (480, 254). Absolute: (960.000000, 508.000000)

    Screen size: Scaled: (960, 509). Absolute: (1920, 1017). Scale factor of 2.000000



-- Affected level --

Details:

    All players: 1 total; [ClientPlayerEntity['Goblin_4el'/192, l='ClientLevel', x=184.17, y=77.00, z=103.61]]

    Chunk stats: Client Chunk Cache: 441, 289

    Level dimension: minecraft:overworld

    Level spawn location: World: (150,67,128), Chunk: (at 6,4,0 in 9,8; contains blocks 144,0,128 to 159,255,143), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)

    Level time: 58542 game time, 58542 day time

    Server brand: vanilla

    Server type: Integrated singleplayer server

Stacktrace:

    at net.minecraft.client.world.ClientWorld.fillCrashReport(ClientWorld.java:530)

    at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2286)

    at net.minecraft.client.Minecraft.run(Minecraft.java:580)

    at net.minecraft.client.main.Main.main(Main.java:186)

    at Start.main(Start.java:11)



-- System Details --

Details:

    Minecraft Version: 1.16.5

    Minecraft Version ID: 1.16.5

    Operating System: Windows 10 (amd64) version 10.0

    Java Version: 17.0.15, Amazon.com Inc.

    Java VM Version: OpenJDK 64-Bit Server VM (mixed mode, sharing), Amazon.com Inc.

    Memory: 1527450104 bytes (1456 MB) / 2210398208 bytes (2108 MB) up to 8573157376 bytes (8176 MB)

    CPUs: 16

    JVM Flags: 0 total;

    Launched Version: OptiFine 1.16.5

    Backend library: LWJGL version 3.2.2 build 10

    Backend API: NVIDIA GeForce RTX 3060/PCIe/SSE2 GL version 4.6.0 NVIDIA 576.40, NVIDIA Corporation

    GL Caps: Using framebuffer using OpenGL 3.0

    Using VBOs: Yes

    Is Modded: Very likely; Jar signature invalidated

    Type: Client (map_client.txt)

    Graphics mode: fancy

    Resource Packs: vanilla

    Current Language: English (US)

    CPU: 16x AMD Ryzen 7 5700X 8-Core Processor

    OptiFine Version: OptiFine_1.16.5_HD_U_G8

    OptiFine Build: ~~NULL~~

    Render Distance Chunks: 8

    Mipmaps: 4

    Anisotropic Filtering: 1

    Antialiasing: 0

    Multitexture: false

    Shaders: null

    OpenGlVersion: 4.6.0 NVIDIA 576.40

    OpenGlRenderer: NVIDIA GeForce RTX 3060/PCIe/SSE2

    OpenGlVendor: NVIDIA Corporation

    CpuCount: 16

#@!@# Game crashed! Crash report saved to: #@!@# C:\Users\golov\Desktop\src\123123\.\crash-reports\crash-2025-05-31_14.45.50-client.txt

Disconnected from the target VM, address: '127.0.0.1:63703', transport: 'socket'

AL lib: (EE) alc_cleanup: 1 device not closed



Process finished with exit code -1
ContainerScreen:
Expand Collapse Copy
package net.minecraft.client.gui.screen.inventory;

import com.google.common.collect.Sets;
import com.mojang.datafixers.util.Pair;


import i.chuppachups.deadcore.Main.FeatureManager.api.ModuleManager;
import i.chuppachups.deadcore.Main.FeatureManager.impl.misc.InventoryPlus;
import i.chuppachups.deadcore.Main.Ready;
import i.chuppachups.deadcore.Other.Helper.blaze3d.matrix.MatrixStack;
import i.chuppachups.deadcore.Other.Helper.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.IHasContainer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.util.InputMappings;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ClickType;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import org.lwjgl.glfw.GLFW;

import javax.annotation.Nullable;
import java.util.Set;

public abstract class ContainerScreen<T extends Container> extends Screen implements IHasContainer<T> {
    /**
     * The location of the inventory background texture
     */
    public static final ResourceLocation INVENTORY_BACKGROUND = new ResourceLocation("textures/gui/container/inventory.png");

    /**
     * The X size of the inventory window in pixels.
     */
    public int xSize = 176;

    /**
     * The Y size of the inventory window in pixels.
     */
    public int ySize = 166;
    protected int titleX;
    protected int titleY;
    protected int playerInventoryTitleX;
    protected int playerInventoryTitleY;

    /**
     * A list of the players inventory slots
     */
    protected final T container;
    protected final PlayerInventory playerInventory;
    [USER=1265501]@nullable[/USER]

    /** Holds the slot currently hovered */
    protected Slot hoveredSlot;
    [USER=1265501]@nullable[/USER]

    /** Used when touchscreen is enabled */
    private Slot clickedSlot;
    [USER=1265501]@nullable[/USER]
    private Slot returningStackDestSlot;
    [USER=1265501]@nullable[/USER]
    private Slot currentDragTargetSlot;
    [USER=1265501]@nullable[/USER]
    private Slot lastClickSlot;

    /**
     * Starting X position for the Gui. Inconsistent use for Gui backgrounds.
     */
    protected int guiLeft;

    /**
     * Starting Y position for the Gui. Inconsistent use for Gui backgrounds.
     */
    protected int guiTop;

    /**
     * Used when touchscreen is enabled.
     */
    private boolean isRightMouseClick;

    /**
     * Used when touchscreen is enabled
     */
    private ItemStack draggedStack = ItemStack.EMPTY;
    private int touchUpX;
    private int touchUpY;
    private long returningStackTime;

    /**
     * Used when touchscreen is enabled
     */
    private ItemStack returningStack = ItemStack.EMPTY;
    private long dragItemDropDelay;
    protected final Set<Slot> dragSplittingSlots = Sets.newHashSet();
    protected boolean dragSplitting;
    private int dragSplittingLimit;
    private int dragSplittingButton;
    private boolean ignoreMouseUp;
    private int dragSplittingRemnant;
    private long lastClickTime;
    private int lastClickButton;
    private boolean doubleClick;
    private ItemStack shiftClickedSlot = ItemStack.EMPTY;

    public ContainerScreen(T screenContainer, PlayerInventory inv, ITextComponent titleIn) {
        super(titleIn);
        this.container = screenContainer;
        this.playerInventory = inv;
        this.ignoreMouseUp = true;
        this.titleX = 8;
        this.titleY = 6;
        this.playerInventoryTitleX = 8;
        this.playerInventoryTitleY = this.ySize - 94;
    }

    [USER=1367676]@override[/USER]
    protected void init() {
        super.init();
        this.guiLeft = (this.width - this.xSize) / 2;
        this.guiTop = (this.height - this.ySize) / 2;
    }

    [USER=1367676]@override[/USER]
    public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
        int i = this.guiLeft;
        int j = this.guiTop;
        this.drawGuiContainerBackgroundLayer(matrixStack, partialTicks, mouseX, mouseY);
        RenderSystem.disableRescaleNormal();
        RenderSystem.disableDepthTest();
        super.render(matrixStack, mouseX, mouseY, partialTicks);
        RenderSystem.pushMatrix();
        RenderSystem.translatef((float) i, (float) j, 0.0F);
        RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
        RenderSystem.enableRescaleNormal();
        this.hoveredSlot = null;
        int k = 240;
        int l = 240;
        RenderSystem.glMultiTexCoord2f(33986, 240.0F, 240.0F);
        RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);

        for (int i1 = 0; i1 < this.container.inventorySlots.size(); ++i1) {
            Slot slot = this.container.inventorySlots.get(i1);

            if (slot.isEnabled()) {
                this.moveItems(matrixStack, slot);
            }

            if (this.isSlotSelected(slot, (double) mouseX, (double) mouseY) && slot.isEnabled()) {

                ModuleManager moduleManager = Ready.getInst().getModuleManager();
                InventoryPlus inventoryPlus = moduleManager.getInventoryPlus();
                if (inventoryPlus.itemScroller.getValue() && inventoryPlus.isEnabled()) {
                    if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_LEFT) == GLFW.GLFW_PRESS
                            && GLFW.glfwGetKey(Minecraft.getInstance().getMainWindow().getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT) == GLFW.GLFW_PRESS
                            && slot.getStack().getItem() != Items.AIR)
                        handleMouseClick(slot, slot.slotNumber, 0, ClickType.QUICK_MOVE);
                }

                this.hoveredSlot = slot;
                RenderSystem.disableDepthTest();
                int j1 = slot.xPos;
                int k1 = slot.yPos;
                RenderSystem.colorMask(true, true, true, false);
                this.fillGradient(matrixStack, j1, k1, j1 + 16, k1 + 16, -2130706433, -2130706433);
                RenderSystem.colorMask(true, true, true, true);
                RenderSystem.enableDepthTest();
            }
        }

        this.drawGuiContainerForegroundLayer(matrixStack, mouseX, mouseY);
        PlayerInventory playerinventory = this.minecraft.player.inventory;
        ItemStack itemstack = this.draggedStack.isEmpty() ? playerinventory.getItemStack() : this.draggedStack;

        if (!itemstack.isEmpty()) {
            int j2 = 8;
            int k2 = this.draggedStack.isEmpty() ? 8 : 16;
            String s = null;

            if (!this.draggedStack.isEmpty() && this.isRightMouseClick) {
                itemstack = itemstack.copy();
                itemstack.setCount(MathHelper.ceil((float) itemstack.getCount() / 2.0F));
            } else if (this.dragSplitting && this.dragSplittingSlots.size() > 1) {
                itemstack = itemstack.copy();
                itemstack.setCount(this.dragSplittingRemnant);

                if (itemstack.isEmpty()) {
                    s = "" + TextFormatting.YELLOW + "0";
                }
            }

            this.drawItemStack(itemstack, mouseX - i - 8, mouseY - j - k2, s);
        }

        if (!this.returningStack.isEmpty()) {
            float f = (float) (Util.milliTime() - this.returningStackTime) / 100.0F;

            if (f >= 1.0F) {
                f = 1.0F;
                this.returningStack = ItemStack.EMPTY;
            }

            int l2 = this.returningStackDestSlot.xPos - this.touchUpX;
            int i3 = this.returningStackDestSlot.yPos - this.touchUpY;
            int l1 = this.touchUpX + (int) ((float) l2 * f);
            int i2 = this.touchUpY + (int) ((float) i3 * f);
            this.drawItemStack(this.returningStack, l1, i2, (String) null);
        }

        RenderSystem.popMatrix();
        RenderSystem.enableDepthTest();
    }

    protected void renderHoveredTooltip(MatrixStack matrixStack, int x, int y) {
        if (this.minecraft.player.inventory.getItemStack().isEmpty() && this.hoveredSlot != null && this.hoveredSlot.getHasStack()) {
            this.renderTooltip(matrixStack, this.hoveredSlot.getStack(), x, y);
        }
    }

    /**
     * Draws an ItemStack.
     * <p>
     * The z index is increased by 32 (and not decreased afterwards), and the item is then rendered at z=200.
     */
    private void drawItemStack(ItemStack stack, int x, int y, String altText) {
        RenderSystem.translatef(0.0F, 0.0F, 32.0F);
        this.setBlitOffset(200);
        this.itemRenderer.zLevel = 200.0F;
        this.itemRenderer.renderItemAndEffectIntoGUI(stack, x, y);
        this.itemRenderer.renderItemOverlayIntoGUI(this.font, stack, x, y - (this.draggedStack.isEmpty() ? 0 : 8), altText);
        this.setBlitOffset(0);
        this.itemRenderer.zLevel = 0.0F;
    }

    protected void drawGuiContainerForegroundLayer(MatrixStack matrixStack, int x, int y) {
        this.font.func_243248_b(matrixStack, this.title, (float) this.titleX, (float) this.titleY, 4210752);
        this.font.func_243248_b(matrixStack, this.playerInventory.getDisplayName(), (float) this.playerInventoryTitleX, (float) this.playerInventoryTitleY, 4210752);
    }

    protected abstract void drawGuiContainerBackgroundLayer(MatrixStack matrixStack, float partialTicks, int x, int y);

    private void moveItems(MatrixStack matrixStack, Slot slot) {
        int i = slot.xPos;
        int j = slot.yPos;
        ItemStack itemstack = slot.getStack();
        boolean flag = false;
        boolean flag1 = slot == this.clickedSlot && !this.draggedStack.isEmpty() && !this.isRightMouseClick;
        ItemStack itemstack1 = this.minecraft.player.inventory.getItemStack();
        String s = null;

        if (slot == this.clickedSlot && !this.draggedStack.isEmpty() && this.isRightMouseClick && !itemstack.isEmpty()) {
            itemstack = itemstack.copy();
            itemstack.setCount(itemstack.getCount() / 2);
        } else if (this.dragSplitting && this.dragSplittingSlots.contains(slot) && !itemstack1.isEmpty()) {
            if (this.dragSplittingSlots.size() == 1) {
                return;
            }

            if (Container.canAddItemToSlot(slot, itemstack1, true) && this.container.canDragIntoSlot(slot)) {
                itemstack = itemstack1.copy();
                flag = true;
                Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack, slot.getStack().isEmpty() ? 0 : slot.getStack().getCount());
                int k = Math.min(itemstack.getMaxStackSize(), slot.getItemStackLimit(itemstack));

                if (itemstack.getCount() > k) {
                    s = TextFormatting.YELLOW.toString() + k;
                    itemstack.setCount(k);
                }
            } else {
                this.dragSplittingSlots.remove(slot);
                this.updateDragSplitting();
            }
        }

        this.setBlitOffset(100);
        this.itemRenderer.zLevel = 100.0F;

        if (itemstack.isEmpty() && slot.isEnabled()) {
            Pair<ResourceLocation, ResourceLocation> pair = slot.getBackground();

            if (pair != null) {
                TextureAtlasSprite textureatlassprite = this.minecraft.getAtlasSpriteGetter(pair.getFirst()).apply(pair.getSecond());
                this.minecraft.getTextureManager().bindTexture(textureatlassprite.getAtlasTexture().getTextureLocation());
                blit(matrixStack, i, j, this.getBlitOffset(), 16, 16, textureatlassprite);
                flag1 = true;
            }
        }

        if (!flag1) {
            if (flag) {
                fill(matrixStack, i, j, i + 16, j + 16, -2130706433);
            }

            RenderSystem.enableDepthTest();
            this.itemRenderer.renderItemAndEffectIntoGUI(this.minecraft.player, itemstack, i, j);
            this.itemRenderer.renderItemOverlayIntoGUI(this.font, itemstack, i, j, s);
        }

        this.itemRenderer.zLevel = 0.0F;
        this.setBlitOffset(0);
    }

    private void updateDragSplitting() {
        ItemStack itemstack = this.minecraft.player.inventory.getItemStack();

        if (!itemstack.isEmpty() && this.dragSplitting) {
            if (this.dragSplittingLimit == 2) {
                this.dragSplittingRemnant = itemstack.getMaxStackSize();
            } else {
                this.dragSplittingRemnant = itemstack.getCount();

                for (Slot slot : this.dragSplittingSlots) {
                    ItemStack itemstack1 = itemstack.copy();
                    ItemStack itemstack2 = slot.getStack();
                    int i = itemstack2.isEmpty() ? 0 : itemstack2.getCount();
                    Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack1, i);
                    int j = Math.min(itemstack1.getMaxStackSize(), slot.getItemStackLimit(itemstack1));

                    if (itemstack1.getCount() > j) {
                        itemstack1.setCount(j);
                    }

                    this.dragSplittingRemnant -= itemstack1.getCount() - i;
                }
            }
        }
    }

    [USER=1265501]@nullable[/USER]
    private Slot getSelectedSlot(double mouseX, double mouseY) {
        for (int i = 0; i < this.container.inventorySlots.size(); ++i) {
            Slot slot = this.container.inventorySlots.get(i);

            if (this.isSlotSelected(slot, mouseX, mouseY) && slot.isEnabled()) {
                return slot;
            }
        }

        return null;
    }

    [USER=1367676]@override[/USER]
    public boolean mouseClicked(double mouseX, double mouseY, int button) {
        if (super.mouseClicked(mouseX, mouseY, button)) {
            return true;
        } else {
            boolean flag = this.minecraft.gameSettings.keyBindPickBlock.matchesMouseKey(button);
            Slot slot = this.getSelectedSlot(mouseX, mouseY);
            long i = Util.milliTime();
            this.doubleClick = this.lastClickSlot == slot && i - this.lastClickTime < 250L && this.lastClickButton == button;
            this.ignoreMouseUp = false;

            if (button != 0 && button != 1 && !flag) {
                this.hotkeySwapItems(button);
            } else {
                int j = this.guiLeft;
                int k = this.guiTop;
                boolean flag1 = this.hasClickedOutside(mouseX, mouseY, j, k, button);
                int l = -1;

                if (slot != null) {
                    l = slot.slotNumber;
                }

                if (flag1) {
                    l = -999;
                }

                if (this.minecraft.gameSettings.touchscreen && flag1 && this.minecraft.player.inventory.getItemStack().isEmpty()) {
                    this.minecraft.displayGuiScreen((Screen) null);
                    return true;
                }

                if (l != -1) {
                    if (this.minecraft.gameSettings.touchscreen) {
                        if (slot != null && slot.getHasStack()) {
                            this.clickedSlot = slot;
                            this.draggedStack = ItemStack.EMPTY;
                            this.isRightMouseClick = button == 1;
                        } else {
                            this.clickedSlot = null;
                        }
                    } else if (!this.dragSplitting) {
                        if (this.minecraft.player.inventory.getItemStack().isEmpty()) {
                            if (this.minecraft.gameSettings.keyBindPickBlock.matchesMouseKey(button)) {
                                this.handleMouseClick(slot, l, button, ClickType.CLONE);
                            } else {
                                boolean flag2 = l != -999 && (InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), 340) || InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), 344));
                                ClickType clicktype = ClickType.PICKUP;

                                if (flag2) {
                                    this.shiftClickedSlot = slot != null && slot.getHasStack() ? slot.getStack().copy() : ItemStack.EMPTY;
                                    clicktype = ClickType.QUICK_MOVE;
                                } else if (l == -999) {
                                    clicktype = ClickType.THROW;
                                }

                                this.handleMouseClick(slot, l, button, clicktype);
                            }

                            this.ignoreMouseUp = true;
                        } else {
                            this.dragSplitting = true;
                            this.dragSplittingButton = button;
                            this.dragSplittingSlots.clear();

                            if (button == 0) {
                                this.dragSplittingLimit = 0;
                            } else if (button == 1) {
                                this.dragSplittingLimit = 1;
                            } else if (this.minecraft.gameSettings.keyBindPickBlock.matchesMouseKey(button)) {
                                this.dragSplittingLimit = 2;
                            }
                        }
                    }
                }
            }

            this.lastClickSlot = slot;
            this.lastClickTime = i;
            this.lastClickButton = button;
            return true;
        }
    }

    private void hotkeySwapItems(int keyCode) {
        if (this.hoveredSlot != null && this.minecraft.player.inventory.getItemStack().isEmpty()) {
            if (this.minecraft.gameSettings.keyBindSwapHands.matchesMouseKey(keyCode)) {
                this.handleMouseClick(this.hoveredSlot, this.hoveredSlot.slotNumber, 40, ClickType.SWAP);
                return;
            }

            for (int i = 0; i < 9; ++i) {
                if (this.minecraft.gameSettings.keyBindsHotbar[i].matchesMouseKey(keyCode)) {
                    this.handleMouseClick(this.hoveredSlot, this.hoveredSlot.slotNumber, i, ClickType.SWAP);
                }
            }
        }
    }

    protected boolean hasClickedOutside(double mouseX, double mouseY, int guiLeftIn, int guiTopIn, int mouseButton) {
        return mouseX < (double) guiLeftIn || mouseY < (double) guiTopIn || mouseX >= (double) (guiLeftIn + this.xSize) || mouseY >= (double) (guiTopIn + this.ySize);
    }

    [USER=1367676]@override[/USER]
    public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) {
        Slot slot = this.getSelectedSlot(mouseX, mouseY);
        ItemStack itemstack = this.minecraft.player.inventory.getItemStack();

        if (this.clickedSlot != null && this.minecraft.gameSettings.touchscreen) {
            if (button == 0 || button == 1) {
                if (this.draggedStack.isEmpty()) {
                    if (slot != this.clickedSlot && !this.clickedSlot.getStack().isEmpty()) {
                        this.draggedStack = this.clickedSlot.getStack().copy();
                    }
                } else if (this.draggedStack.getCount() > 1 && slot != null && Container.canAddItemToSlot(slot, this.draggedStack, false)) {
                    long i = Util.milliTime();

                    if (this.currentDragTargetSlot == slot) {
                        if (i - this.dragItemDropDelay > 500L) {
                            this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, ClickType.PICKUP);
                            this.handleMouseClick(slot, slot.slotNumber, 1, ClickType.PICKUP);
                            this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, ClickType.PICKUP);
                            this.dragItemDropDelay = i + 750L;
                            this.draggedStack.shrink(1);
                        }
                    } else {
                        this.currentDragTargetSlot = slot;
                        this.dragItemDropDelay = i;
                    }
                }
            }
        } else if (this.dragSplitting && slot != null && !itemstack.isEmpty() && (itemstack.getCount() > this.dragSplittingSlots.size() || this.dragSplittingLimit == 2) && Container.canAddItemToSlot(slot, itemstack, true) && slot.isItemValid(itemstack) && this.container.canDragIntoSlot(slot)) {
            this.dragSplittingSlots.add(slot);
            this.updateDragSplitting();
        }

        return true;
    }

    [USER=1367676]@override[/USER]
    public boolean mouseReleased(double mouseX, double mouseY, int button) {
        Slot slot = this.getSelectedSlot(mouseX, mouseY);
        int i = this.guiLeft;
        int j = this.guiTop;
        boolean flag = this.hasClickedOutside(mouseX, mouseY, i, j, button);
        int k = -1;

        if (slot != null) {
            k = slot.slotNumber;
        }

        if (flag) {
            k = -999;
        }

        if (this.doubleClick && slot != null && button == 0 && this.container.canMergeSlot(ItemStack.EMPTY, slot)) {
            if (hasShiftDown()) {
                if (!this.shiftClickedSlot.isEmpty()) {
                    for (Slot slot2 : this.container.inventorySlots) {
                        if (slot2 != null && slot2.canTakeStack(this.minecraft.player) && slot2.getHasStack() && slot2.inventory == slot.inventory && Container.canAddItemToSlot(slot2, this.shiftClickedSlot, true)) {
                            this.handleMouseClick(slot2, slot2.slotNumber, button, ClickType.QUICK_MOVE);
                        }
                    }
                }
            } else {
                this.handleMouseClick(slot, k, button, ClickType.PICKUP_ALL);
            }

            this.doubleClick = false;
            this.lastClickTime = 0L;
        } else {
            if (this.dragSplitting && this.dragSplittingButton != button) {
                this.dragSplitting = false;
                this.dragSplittingSlots.clear();
                this.ignoreMouseUp = true;
                return true;
            }

            if (this.ignoreMouseUp) {
                this.ignoreMouseUp = false;
                return true;
            }

            if (this.clickedSlot != null && this.minecraft.gameSettings.touchscreen) {
                if (button == 0 || button == 1) {
                    if (this.draggedStack.isEmpty() && slot != this.clickedSlot) {
                        this.draggedStack = this.clickedSlot.getStack();
                    }

                    boolean flag2 = Container.canAddItemToSlot(slot, this.draggedStack, false);

                    if (k != -1 && !this.draggedStack.isEmpty() && flag2) {
                        this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, button, ClickType.PICKUP);
                        this.handleMouseClick(slot, k, 0, ClickType.PICKUP);

                        if (this.minecraft.player.inventory.getItemStack().isEmpty()) {
                            this.returningStack = ItemStack.EMPTY;
                        } else {
                            this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, button, ClickType.PICKUP);
                            this.touchUpX = MathHelper.floor(mouseX - (double) i);
                            this.touchUpY = MathHelper.floor(mouseY - (double) j);
                            this.returningStackDestSlot = this.clickedSlot;
                            this.returningStack = this.draggedStack;
                            this.returningStackTime = Util.milliTime();
                        }
                    } else if (!this.draggedStack.isEmpty()) {
                        this.touchUpX = MathHelper.floor(mouseX - (double) i);
                        this.touchUpY = MathHelper.floor(mouseY - (double) j);
                        this.returningStackDestSlot = this.clickedSlot;
                        this.returningStack = this.draggedStack;
                        this.returningStackTime = Util.milliTime();
                    }

                    this.draggedStack = ItemStack.EMPTY;
                    this.clickedSlot = null;
                }
            } else if (this.dragSplitting && !this.dragSplittingSlots.isEmpty()) {
                this.handleMouseClick((Slot) null, -999, Container.getQuickcraftMask(0, this.dragSplittingLimit), ClickType.QUICK_CRAFT);

                for (Slot slot1 : this.dragSplittingSlots) {
                    this.handleMouseClick(slot1, slot1.slotNumber, Container.getQuickcraftMask(1, this.dragSplittingLimit), ClickType.QUICK_CRAFT);
                }

                this.handleMouseClick((Slot) null, -999, Container.getQuickcraftMask(2, this.dragSplittingLimit), ClickType.QUICK_CRAFT);
            } else if (!this.minecraft.player.inventory.getItemStack().isEmpty()) {
                if (this.minecraft.gameSettings.keyBindPickBlock.matchesMouseKey(button)) {
                    this.handleMouseClick(slot, k, button, ClickType.CLONE);
                } else {
                    boolean flag1 = k != -999 && (InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), 340) || InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), 344));

                    if (flag1) {
                        this.shiftClickedSlot = slot != null && slot.getHasStack() ? slot.getStack().copy() : ItemStack.EMPTY;
                    }

                    this.handleMouseClick(slot, k, button, flag1 ? ClickType.QUICK_MOVE : ClickType.PICKUP);
                }
            }
        }

        if (this.minecraft.player.inventory.getItemStack().isEmpty()) {
            this.lastClickTime = 0L;
        }

        this.dragSplitting = false;
        return true;
    }

    private boolean isSlotSelected(Slot slotIn, double mouseX, double mouseY) {
        return this.isPointInRegion(slotIn.xPos, slotIn.yPos, 16, 16, mouseX, mouseY);
    }

    protected boolean isPointInRegion(int x, int y, int width, int height, double mouseX, double mouseY) {
        int i = this.guiLeft;
        int j = this.guiTop;
        mouseX = mouseX - (double) i;
        mouseY = mouseY - (double) j;
        return mouseX >= (double) (x - 1) && mouseX < (double) (x + width + 1) && mouseY >= (double) (y - 1) && mouseY < (double) (y + height + 1);
    }

    /**
     * Called when the mouse is clicked over a slot or outside the gui.
     */
    protected void handleMouseClick(Slot slotIn, int slotId, int mouseButton, ClickType type) {
        if (slotIn != null) {
            slotId = slotIn.slotNumber;
        }

        this.minecraft.playerController.windowClick(this.container.windowId, slotId, mouseButton, type, this.minecraft.player);
    }

    [USER=1367676]@override[/USER]
    public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
        if (super.keyPressed(keyCode, scanCode, modifiers)) {
            return true;
        } else if (this.minecraft.gameSettings.keyBindInventory.matchesKey(keyCode, scanCode)) {
            this.closeScreen();
            return true;
        } else {
            this.itemStackMoved(keyCode, scanCode);

            if (this.hoveredSlot != null && this.hoveredSlot.getHasStack()) {
                if (this.minecraft.gameSettings.keyBindPickBlock.matchesKey(keyCode, scanCode)) {
                    this.handleMouseClick(this.hoveredSlot, this.hoveredSlot.slotNumber, 0, ClickType.CLONE);
                } else if (this.minecraft.gameSettings.keyBindDrop.matchesKey(keyCode, scanCode)) {
                    this.handleMouseClick(this.hoveredSlot, this.hoveredSlot.slotNumber, hasControlDown() ? 1 : 0, ClickType.THROW);
                }
            }

            return true;
        }
    }

    protected boolean itemStackMoved(int keyCode, int scanCode) {
        if (this.minecraft.player.inventory.getItemStack().isEmpty() && this.hoveredSlot != null) {
            if (this.minecraft.gameSettings.keyBindSwapHands.matchesKey(keyCode, scanCode)) {
                this.handleMouseClick(this.hoveredSlot, this.hoveredSlot.slotNumber, 40, ClickType.SWAP);
                return true;
            }

            for (int i = 0; i < 9; ++i) {
                if (this.minecraft.gameSettings.keyBindsHotbar[i].matchesKey(keyCode, scanCode)) {
                    this.handleMouseClick(this.hoveredSlot, this.hoveredSlot.slotNumber, i, ClickType.SWAP);
                    return true;
                }
            }
        }

        return false;
    }

    [USER=1367676]@override[/USER]
    public void onClose() {
        if (this.minecraft.player != null) {
            this.container.onContainerClosed(this.minecraft.player);
        }
    }

    [USER=1367676]@override[/USER]
    public boolean isPauseScreen() {
        return false;
    }

    [USER=1367676]@override[/USER]
    public void tick() {
        super.tick();

        if (!this.minecraft.player.isAlive() || this.minecraft.player.removed) {
            this.minecraft.player.closeScreen();
        }
    }

    [USER=1367676]@override[/USER]
    public T getContainer() {
        return this.container;
    }

    [USER=1367676]@override[/USER]
    public void closeScreen() {
        this.minecraft.player.closeScreen();
        super.closeScreen();
    }
}
 
Назад
Сверху Снизу