Skip to content

Commit

Permalink
Make SMP happier some more
Browse files Browse the repository at this point in the history
Apparently GuideText manages to get GuiGuide in the classpool, not a good idea for the server
  • Loading branch information
Chocohead committed Feb 25, 2018
1 parent 500e98c commit 94c90c9
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 34 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repositories {
}
}

version = "2.1.1"
version = "2.1.2"
group = "com.chocohead.eumj"
archivesBaseName = "EU-MJ Engine"

Expand Down
38 changes: 5 additions & 33 deletions src/com/chocohead/eumj/EngineMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.io.File;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;

import net.minecraft.creativetab.CreativeTabs;
Expand Down Expand Up @@ -33,12 +32,6 @@
import buildcraft.api.blocks.CustomRotationHelper;
import buildcraft.api.enums.EnumEngineType;
import buildcraft.api.mj.MjAPI;
import buildcraft.lib.client.guide.GuideManager;
import buildcraft.lib.client.guide.PageLine;
import buildcraft.lib.client.guide.loader.XmlPageLoader;
import buildcraft.lib.client.guide.parts.GuideText;
import buildcraft.lib.gui.GuiStack;
import buildcraft.lib.gui.ISimpleDrawable;
import buildcraft.transport.BCTransportItems;

import ic2.api.event.TeBlockFinalCallEvent;
Expand Down Expand Up @@ -203,32 +196,11 @@ public void init(FMLInitializationEvent event) {
}
}

//BuildCraft bounces the loading of Markdown into XML anyway, we'll just go straight there thank you.
GuideManager.PAGE_LOADERS.put("xml", XmlPageLoader.INSTANCE);

//BuildCraft Lib loads pages in post-init, but it also loads first, so we do this here
XmlPageLoader.TAG_FACTORIES.put("engineLink", tag -> {
ItemStack stack = XmlPageLoader.loadItemStack(tag);

PageLine line;
if (StackUtil.isEmpty(stack)) {
line = new PageLine(1, "Missing item: "+tag, false);
} else {
ISimpleDrawable icon = new GuiStack(stack);
line = new PageLine(icon, icon, 1, stack.getDisplayName(), true);
}

return Collections.singletonList(gui -> new GuideText(gui, line) {
@Override
public PagePosition handleMouseClick(int x, int y, int width, int height, PagePosition current, int index, int mouseX, int mouseY) {
if (line.link && (wasHovered || wasIconHovered)) {
gui.openPage(GuideManager.INSTANCE.getPageFor(stack).createNew(gui));
}

return renderLine(current, text, x, y, width, height, -1);
}
});
});
if (event.getSide().isClient()) {
//BuildCraft Lib loads pages in post-init, but it also loads first, so we do this here
GuideThings.addLoaders();
GuideThings.addTags();
}
}

private static ItemStack anyCharge(ItemStack stack) {
Expand Down
51 changes: 51 additions & 0 deletions src/com/chocohead/eumj/GuideThings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.chocohead.eumj;

import java.util.Collections;

import net.minecraft.item.ItemStack;

import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import buildcraft.lib.client.guide.GuideManager;
import buildcraft.lib.client.guide.PageLine;
import buildcraft.lib.client.guide.loader.XmlPageLoader;
import buildcraft.lib.client.guide.parts.GuideText;
import buildcraft.lib.gui.GuiStack;
import buildcraft.lib.gui.ISimpleDrawable;

import ic2.core.util.StackUtil;

class GuideThings {
@SideOnly(Side.CLIENT)
public static void addLoaders() {
//BuildCraft bounces the loading of Markdown into XML anyway, we'll just go straight there thank you.
GuideManager.PAGE_LOADERS.put("xml", XmlPageLoader.INSTANCE);
}

@SideOnly(Side.CLIENT)
public static void addTags() {
XmlPageLoader.TAG_FACTORIES.put("engineLink", tag -> {
ItemStack stack = XmlPageLoader.loadItemStack(tag);

PageLine line;
if (StackUtil.isEmpty(stack)) {
line = new PageLine(1, "Missing item: "+tag, false);
} else {
ISimpleDrawable icon = new GuiStack(stack);
line = new PageLine(icon, icon, 1, stack.getDisplayName(), true);
}

return Collections.singletonList(gui -> new GuideText(gui, line) {
@Override
public PagePosition handleMouseClick(int x, int y, int width, int height, PagePosition current, int index, int mouseX, int mouseY) {
if (line.link && (wasHovered || wasIconHovered)) {
gui.openPage(GuideManager.INSTANCE.getPageFor(stack).createNew(gui));
}

return renderLine(current, text, x, y, width, height, -1);
}
});
});
}
}

0 comments on commit 94c90c9

Please sign in to comment.