From fef4155f2c1b20f30491977a7fda7f13f6e9ec26 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sun, 23 Sep 2018 12:38:34 +0200 Subject: [PATCH] Fix problem with classloading. Fixes #2008 --- .../TileDataParameterClientListenerCrafter.java | 15 +++++++++++++++ .../refinedstorage/tile/TileCrafter.java | 12 ++---------- 2 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/raoulvdberge/refinedstorage/gui/TileDataParameterClientListenerCrafter.java diff --git a/src/main/java/com/raoulvdberge/refinedstorage/gui/TileDataParameterClientListenerCrafter.java b/src/main/java/com/raoulvdberge/refinedstorage/gui/TileDataParameterClientListenerCrafter.java new file mode 100644 index 000000000..2e102f57d --- /dev/null +++ b/src/main/java/com/raoulvdberge/refinedstorage/gui/TileDataParameterClientListenerCrafter.java @@ -0,0 +1,15 @@ +package com.raoulvdberge.refinedstorage.gui; + +import com.raoulvdberge.refinedstorage.gui.control.SideButtonCrafterMode; +import com.raoulvdberge.refinedstorage.tile.data.TileDataParameterClientListener; + +public class TileDataParameterClientListenerCrafter implements TileDataParameterClientListener { + @Override + public void onChanged(boolean initial, Boolean hasRoot) { + if (!hasRoot) { + GuiBase.executeLater(GuiCrafter.class, gui -> { + gui.addSideButton(new SideButtonCrafterMode(gui)); + }); + } + } +} diff --git a/src/main/java/com/raoulvdberge/refinedstorage/tile/TileCrafter.java b/src/main/java/com/raoulvdberge/refinedstorage/tile/TileCrafter.java index 7a9e0e7a0..9efe63bc8 100755 --- a/src/main/java/com/raoulvdberge/refinedstorage/tile/TileCrafter.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/tile/TileCrafter.java @@ -1,9 +1,7 @@ package com.raoulvdberge.refinedstorage.tile; import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCrafter; -import com.raoulvdberge.refinedstorage.gui.GuiBase; -import com.raoulvdberge.refinedstorage.gui.GuiCrafter; -import com.raoulvdberge.refinedstorage.gui.control.SideButtonCrafterMode; +import com.raoulvdberge.refinedstorage.gui.TileDataParameterClientListenerCrafter; import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.util.EnumFacing; @@ -18,13 +16,7 @@ import javax.annotation.Nullable; public class TileCrafter extends TileNode { public static final TileDataParameter NAME = new TileDataParameter<>(DataSerializers.STRING, NetworkNodeCrafter.DEFAULT_NAME, t -> t.getNode().getName()); public static final TileDataParameter MODE = new TileDataParameter<>(DataSerializers.VARINT, NetworkNodeCrafter.CrafterMode.IGNORE.ordinal(), t -> t.getNode().getMode().ordinal(), (t, v) -> t.getNode().setMode(NetworkNodeCrafter.CrafterMode.getById(v))); - public static final TileDataParameter HAS_ROOT = new TileDataParameter<>(DataSerializers.BOOLEAN, false, t -> t.getNode().getRootContainerNotSelf().isPresent(), null, (t, hasRoot) -> { - if (!hasRoot) { - GuiBase.executeLater(GuiCrafter.class, gui -> { - gui.addSideButton(new SideButtonCrafterMode(gui)); - }); - } - }); + private static final TileDataParameter HAS_ROOT = new TileDataParameter<>(DataSerializers.BOOLEAN, false, t -> t.getNode().getRootContainerNotSelf().isPresent(), null, (t, v) -> new TileDataParameterClientListenerCrafter().onChanged(t, v)); public TileCrafter() { dataManager.addWatchedParameter(NAME);