From 88f669f681d15597ef6d413e372efdde6e784f58 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Tue, 31 Jan 2023 21:41:25 +0100 Subject: [PATCH] fix: avoid server crash due to loading button class --- .../internal/grid/AbstractGridSynchronizer.java | 4 ++-- .../storage/channel/FluidStorageChannelType.java | 4 ++-- .../storage/channel/ItemStorageChannelType.java | 4 ++-- .../platform/common/screen/TextureIds.java | 12 ++++++++++++ .../grid/StorageChannelTypeSideButtonWidget.java | 3 ++- .../screen/widget/AbstractSideButtonWidget.java | 8 +++----- 6 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/screen/TextureIds.java diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/grid/AbstractGridSynchronizer.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/grid/AbstractGridSynchronizer.java index cd19bdb67..0363fd554 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/grid/AbstractGridSynchronizer.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/grid/AbstractGridSynchronizer.java @@ -1,14 +1,14 @@ package com.refinedmods.refinedstorage2.platform.common.internal.grid; import com.refinedmods.refinedstorage2.platform.api.grid.GridSynchronizer; -import com.refinedmods.refinedstorage2.platform.common.screen.widget.AbstractSideButtonWidget; +import com.refinedmods.refinedstorage2.platform.common.screen.TextureIds; import net.minecraft.resources.ResourceLocation; public abstract class AbstractGridSynchronizer implements GridSynchronizer { @Override public ResourceLocation getTextureIdentifier() { - return AbstractSideButtonWidget.DEFAULT_TEXTURE; + return TextureIds.ICONS; } @Override diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/channel/FluidStorageChannelType.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/channel/FluidStorageChannelType.java index 0d6ac33f8..d6624e7c3 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/channel/FluidStorageChannelType.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/channel/FluidStorageChannelType.java @@ -13,7 +13,7 @@ import com.refinedmods.refinedstorage2.platform.common.Platform; import com.refinedmods.refinedstorage2.platform.common.internal.grid.view.FluidGridResource; import com.refinedmods.refinedstorage2.platform.common.internal.resource.filter.fluid.FluidFilteredResource; -import com.refinedmods.refinedstorage2.platform.common.screen.widget.AbstractSideButtonWidget; +import com.refinedmods.refinedstorage2.platform.common.screen.TextureIds; import com.refinedmods.refinedstorage2.platform.common.util.PacketUtil; import java.util.Optional; @@ -33,7 +33,7 @@ class FluidStorageChannelType extends AbstractPlatformStorageChannelType(fuzzyList); }, createTranslation("misc", "storage_channel_type.fluid"), - AbstractSideButtonWidget.DEFAULT_TEXTURE, + TextureIds.ICONS, 16, 128 ); diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/channel/ItemStorageChannelType.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/channel/ItemStorageChannelType.java index c61ec67d9..588a0510d 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/channel/ItemStorageChannelType.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/channel/ItemStorageChannelType.java @@ -13,7 +13,7 @@ import com.refinedmods.refinedstorage2.platform.common.Platform; import com.refinedmods.refinedstorage2.platform.common.internal.grid.view.ItemGridResource; import com.refinedmods.refinedstorage2.platform.common.internal.resource.filter.item.ItemFilteredResource; -import com.refinedmods.refinedstorage2.platform.common.screen.widget.AbstractSideButtonWidget; +import com.refinedmods.refinedstorage2.platform.common.screen.TextureIds; import com.refinedmods.refinedstorage2.platform.common.util.PacketUtil; import java.util.Optional; @@ -33,7 +33,7 @@ class ItemStorageChannelType extends AbstractPlatformStorageChannelType(fuzzyList); }, createTranslation("misc", "storage_channel_type.item"), - AbstractSideButtonWidget.DEFAULT_TEXTURE, + TextureIds.ICONS, 0, 128 ); diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/screen/TextureIds.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/screen/TextureIds.java new file mode 100644 index 000000000..e76b05f66 --- /dev/null +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/screen/TextureIds.java @@ -0,0 +1,12 @@ +package com.refinedmods.refinedstorage2.platform.common.screen; + +import net.minecraft.resources.ResourceLocation; + +import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createIdentifier; + +public final class TextureIds { + public static final ResourceLocation ICONS = createIdentifier("textures/icons.png"); + + private TextureIds() { + } +} diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/screen/grid/StorageChannelTypeSideButtonWidget.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/screen/grid/StorageChannelTypeSideButtonWidget.java index 9dfb5fbec..b5241e2cd 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/screen/grid/StorageChannelTypeSideButtonWidget.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/screen/grid/StorageChannelTypeSideButtonWidget.java @@ -2,6 +2,7 @@ import com.refinedmods.refinedstorage2.platform.api.storage.channel.PlatformStorageChannelType; import com.refinedmods.refinedstorage2.platform.common.containermenu.GridContainerMenu; +import com.refinedmods.refinedstorage2.platform.common.screen.TextureIds; import com.refinedmods.refinedstorage2.platform.common.screen.TooltipRenderer; import com.refinedmods.refinedstorage2.platform.common.screen.widget.AbstractSideButtonWidget; @@ -55,7 +56,7 @@ private static List calculateTooltip(@Nullable final PlatformStorageC protected ResourceLocation getTextureIdentifier() { final PlatformStorageChannelType storageChannelType = menu.getStorageChannelType(); if (storageChannelType == null) { - return AbstractSideButtonWidget.DEFAULT_TEXTURE; + return TextureIds.ICONS; } return storageChannelType.getTextureIdentifier(); } diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/screen/widget/AbstractSideButtonWidget.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/screen/widget/AbstractSideButtonWidget.java index 76c67ffc3..af0bcab28 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/screen/widget/AbstractSideButtonWidget.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/screen/widget/AbstractSideButtonWidget.java @@ -1,5 +1,7 @@ package com.refinedmods.refinedstorage2.platform.common.screen.widget; +import com.refinedmods.refinedstorage2.platform.common.screen.TextureIds; + import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.components.Button; @@ -8,11 +10,7 @@ import net.minecraft.resources.ResourceLocation; import org.lwjgl.opengl.GL11; -import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createIdentifier; - public abstract class AbstractSideButtonWidget extends Button { - public static final ResourceLocation DEFAULT_TEXTURE = createIdentifier("textures/icons.png"); - private static final int WIDTH = 18; private static final int HEIGHT = 18; @@ -25,7 +23,7 @@ protected AbstractSideButtonWidget(final OnPress pressAction) { protected abstract int getYTexture(); protected ResourceLocation getTextureIdentifier() { - return DEFAULT_TEXTURE; + return TextureIds.ICONS; } @Override