Skip to content

Commit

Permalink
Merge pull request #309 from refinedmods/fix/GH-243/server-loading
Browse files Browse the repository at this point in the history
fix: avoid server crash due to loading button class
  • Loading branch information
raoulvdberge authored Jan 31, 2023
2 parents f5f24d7 + 88f669f commit 302cfc9
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,7 +33,7 @@ class FluidStorageChannelType extends AbstractPlatformStorageChannelType<FluidRe
return new FuzzyStorageChannelImpl<>(fuzzyList);
},
createTranslation("misc", "storage_channel_type.fluid"),
AbstractSideButtonWidget.DEFAULT_TEXTURE,
TextureIds.ICONS,
16,
128
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,7 +33,7 @@ class ItemStorageChannelType extends AbstractPlatformStorageChannelType<ItemReso
return new FuzzyStorageChannelImpl<>(fuzzyList);
},
createTranslation("misc", "storage_channel_type.item"),
AbstractSideButtonWidget.DEFAULT_TEXTURE,
TextureIds.ICONS,
0,
128
);
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -55,7 +56,7 @@ private static List<Component> 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();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand All @@ -25,7 +23,7 @@ protected AbstractSideButtonWidget(final OnPress pressAction) {
protected abstract int getYTexture();

protected ResourceLocation getTextureIdentifier() {
return DEFAULT_TEXTURE;
return TextureIds.ICONS;
}

@Override
Expand Down

0 comments on commit 302cfc9

Please sign in to comment.