mirror of
https://github.com/GTNewHorizons/JustEnoughCalculation.git
synced 2026-11-19 11:49:06 +00:00
feat: add ThuamCraft support
- re add command to open gui - update nei version
This commit is contained in:
1 parent
343cf48cfa
commit
e5767d75ab
11 files changed
+78
-12
No files matched your search
@@ -43,6 +43,10 @@ public class Adapter {
|
||||
JustEnoughCalculation.logger.info("EnderIO installed");
|
||||
adapters.add(new EnderIO());
|
||||
}
|
||||
if (Loader.isModLoaded("thaumcraftneiplugin")) {
|
||||
adapters.add(new Thaum());
|
||||
JustEnoughCalculation.logger.info("Thaumcraft installed");
|
||||
}
|
||||
JustEnoughCalculation.logger.info("=====Just Enough Calculation Init Finish=====");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package me.towdium.jecalculation.nei.adapter;
|
||||
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public class Thaum implements IAdapter {
|
||||
@Override
|
||||
public Set<String> getAllOverlayIdentifier() {
|
||||
return new HashSet<>(
|
||||
Arrays.asList("arcaneshapedrecipes", "arcaneshapelessrecipes", "aspectsRecipe", "cruciblerecipe",
|
||||
"infusionCrafting"));
|
||||
}
|
||||
|
||||
private final static Set<Class<?>> defaultHandlers;
|
||||
|
||||
static {
|
||||
List<String> handlers = Stream.of("ArcaneShapedRecipeHandler", "ArcaneShapelessRecipeHandler",
|
||||
"AspectRecipeHandler", "CrucibleRecipeHandler", "InfusionRecipeHandler")
|
||||
.map(name -> "com.djgiannuzz.thaumcraftneiplugin.nei.recipehandler." + name)
|
||||
.collect(Collectors.toList());
|
||||
defaultHandlers = new HashSet<>();
|
||||
for (String handler : handlers) {
|
||||
try {
|
||||
defaultHandlers.add(Class.forName(handler));
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRecipe(IRecipeHandler recipe, int index, List<Object[]> inputs, List<Object[]> outputs) {
|
||||
if (defaultHandlers.stream().anyMatch(handler -> handler.isInstance(recipe))) {
|
||||
// remove all aspects
|
||||
Iterator<Object[]> it = inputs.iterator();
|
||||
while (it.hasNext()) {
|
||||
Object[] items = it.next();
|
||||
for (Object item : items) {
|
||||
if (item instanceof ItemStack) {
|
||||
String name = GameData.getItemRegistry().getNameForObject(((ItemStack) item).getItem());
|
||||
if ("thaumcraftneiplugin:Aspect".equals(name)) {
|
||||
it.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,11 @@ package me.towdium.jecalculation.network;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import me.towdium.jecalculation.command.JecaCommand;
|
||||
import me.towdium.jecalculation.data.Controller;
|
||||
import me.towdium.jecalculation.data.label.ILabel;
|
||||
import me.towdium.jecalculation.event.Handlers;
|
||||
import net.minecraftforge.client.ClientCommandHandler;
|
||||
|
||||
import static me.towdium.jecalculation.gui.JecaGui.keyOpenGuiCraft;
|
||||
import static me.towdium.jecalculation.gui.JecaGui.keyOpenGuiMath;
|
||||
@@ -19,8 +21,7 @@ public class ClientHandler {
|
||||
|
||||
public void initPost() {
|
||||
ILabel.initServer();
|
||||
// May crash: `NoSuchMethodError`.
|
||||
// ClientCommandHandler.instance.registerCommand(new JecaCommand());
|
||||
ClientCommandHandler.instance.registerCommand(new JecaCommand());
|
||||
ILabel.initClient();
|
||||
Controller.loadFromLocal();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,11 @@ public class ClientUtils {
|
||||
}
|
||||
|
||||
public static void playClickSound(float pitchIn) {
|
||||
mc().getSoundHandler().playSound(
|
||||
PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), pitchIn));
|
||||
try {
|
||||
mc().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), pitchIn));
|
||||
} catch (Exception e) {
|
||||
// why may crash ??
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import me.towdium.jecalculation.JustEnoughCalculation;
|
||||
import me.towdium.jecalculation.polyfill.NBTHelper;
|
||||
import me.towdium.jecalculation.utils.wrappers.Pair;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -21,7 +20,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
@@ -144,7 +142,7 @@ public class Utilities {
|
||||
}
|
||||
|
||||
public static EntityClientPlayerMP getPlayer() {
|
||||
return Objects.requireNonNull(Minecraft.getMinecraft().thePlayer);
|
||||
return Objects.requireNonNull(ClientUtils.mc().thePlayer);
|
||||
}
|
||||
|
||||
|
||||
@@ -281,12 +279,12 @@ public class Utilities {
|
||||
|
||||
public static List<String> wrap(String s, int width) {
|
||||
return new TextWrapper()
|
||||
.wrap(s, Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode(),
|
||||
.wrap(s, ClientUtils.mc().getLanguageManager().getCurrentLanguage().getLanguageCode(),
|
||||
i -> TextWrapper.renderer.getCharWidth(i), width);
|
||||
}
|
||||
|
||||
static class TextWrapper {
|
||||
static FontRenderer renderer = Minecraft.getMinecraft().fontRenderer;
|
||||
static FontRenderer renderer = ClientUtils.mc().fontRenderer;
|
||||
|
||||
String str;
|
||||
BreakIterator it;
|
||||
|
||||
Reference in new issue
Block a user