there is more

This commit is contained in:
Alexdoru committed 2022-09-11 22:25:56 +02:00
1 parent c5adb9c85b
commit 7cd70520ca
4 files changed
+59 -62

No files matched your search

@@ -129,7 +129,6 @@ public class NEINeeConfig implements IConfigureNEI {
}
if (Loader.isModLoaded("thaumcraftneiplugin")) {
NotEnoughEnergistics.logger.info("Install ThaumicEnergistics support");
API.registerGuiOverlay(GuiKnowledgeInscriber.class, "arcaneshapedrecipes");
API.registerGuiOverlay(GuiKnowledgeInscriber.class, "arcaneshapelessrecipes");
API.registerGuiOverlayHandler(GuiKnowledgeInscriber.class, new NEECraftingHandler(), "arcaneshapedrecipes");
@@ -161,7 +160,6 @@ public class NEINeeConfig implements IConfigureNEI {
}
if (Loader.isModLoaded("avaritiaddons")) {
NotEnoughEnergistics.logger.info("Install Avaritiaddons support");
API.registerGuiOverlay(GuiExtremeAutoCrafter.class, "extreme");
API.registerGuiOverlayHandler(GuiExtremeAutoCrafter.class, new NEECraftingHandler(), "extreme");
}
@@ -34,6 +34,25 @@ public class NEECraftingHandler implements IOverlayHandler {
public static Map<String, PositionedStack> ingredients = new HashMap<>();
public static final NEECraftingHandler INSTANCE = new NEECraftingHandler();
private static Class<?> knowledgeInscriberClz;
private static Class<?> itemAspectClz;
private static Class<?> guiExtremeAutoCrafterClz;
static {
try {
knowledgeInscriberClz = Class.forName("thaumicenergistics.client.gui.GuiKnowledgeInscriber");
} catch (ClassNotFoundException ignored) {
}
try {
itemAspectClz = Class.forName("com.djgiannuzz.thaumcraftneiplugin.items.ItemAspect");
} catch (ClassNotFoundException ignored) {
}
try {
guiExtremeAutoCrafterClz =
Class.forName("wanion.avaritiaddons.block.extremeautocrafter.GuiExtremeAutoCrafter");
} catch (ClassNotFoundException ignored) {
}
}
public static boolean isCraftingTableRecipe(IRecipeHandler recipe) {
if (recipe instanceof TemplateRecipeHandler) {
@@ -66,9 +85,7 @@ public class NEECraftingHandler implements IOverlayHandler {
private PacketNEIPatternRecipe packProcessRecipe(IRecipeHandler recipe, int recipeIndex) {
final NBTTagCompound recipeInputs = new NBTTagCompound();
NBTTagCompound recipeOutputs = new NBTTagCompound();
String identifier = recipe instanceof TemplateRecipeHandler
? ((TemplateRecipeHandler) recipe).getOverlayIdentifier()
: NULL_IDENTIFIER;
String identifier = recipe instanceof TemplateRecipeHandler ? recipe.getOverlayIdentifier() : NULL_IDENTIFIER;
if (identifier == null) {
identifier = NULL_IDENTIFIER;
}
@@ -198,33 +215,18 @@ public class NEECraftingHandler implements IOverlayHandler {
}
private void knowledgeInscriberHandler(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex) {
Class<?> knowledgeInscriberClz;
try {
knowledgeInscriberClz = Class.forName("thaumicenergistics.client.gui.GuiKnowledgeInscriber");
} catch (ClassNotFoundException e) {
return;
}
if (knowledgeInscriberClz.isInstance(firstGui)) {
if (knowledgeInscriberClz != null && knowledgeInscriberClz.isInstance(firstGui)) {
NEENetworkHandler.getInstance().sendToServer(packetArcaneRecipe(recipe, recipeIndex));
}
}
private PacketArcaneRecipe packetArcaneRecipe(IRecipeHandler recipe, int recipeIndex) {
final Class<?> itemAspectClz;
Class<?> iA = null;
try {
iA = Class.forName("com.djgiannuzz.thaumcraftneiplugin.items.ItemAspect");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
itemAspectClz = iA;
final NBTTagCompound recipeInputs = new NBTTagCompound();
List<PositionedStack> ingredients = recipe.getIngredientStacks(recipeIndex);
if (itemAspectClz != null) {
ingredients.removeIf(positionedStack -> itemAspectClz.isInstance(positionedStack.item.getItem()));
}
for (PositionedStack positionedStack : ingredients) {
if (positionedStack.items != null && positionedStack.items.length > 0) {
int slotIndex = getSlotIndex(positionedStack.relx * 100 + positionedStack.rely);
final ItemStack[] currentStackList = positionedStack.items;
@@ -241,14 +243,7 @@ public class NEECraftingHandler implements IOverlayHandler {
}
private void extremeAutoCrafterHandler(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex) {
final Class<?> guiExtremeAutoCrafterClz;
try {
guiExtremeAutoCrafterClz =
Class.forName("wanion.avaritiaddons.block.extremeautocrafter.GuiExtremeAutoCrafter");
} catch (ClassNotFoundException e) {
return;
}
if (guiExtremeAutoCrafterClz.isInstance(firstGui)) {
if (guiExtremeAutoCrafterClz != null && guiExtremeAutoCrafterClz.isInstance(firstGui)) {
NEENetworkHandler.getInstance().sendToServer(packetExtremeRecipe(recipe, recipeIndex));
}
}
@@ -10,6 +10,17 @@ import javax.annotation.Nonnull;
public class ThermalExpansionRecipeProcessor implements IRecipeProcessor {
private static Class<?> thermalNeiRecipeBaseClass;
static {
try {
thermalNeiRecipeBaseClass =
Class.forName("cofh.thermalexpansion.plugins.nei.handlers.RecipeHandlerBase$NEIRecipeBase");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
@Nonnull
@Override
public Set<String> getAllOverlayIdentifier() {
@@ -37,15 +48,8 @@ public class ThermalExpansionRecipeProcessor implements IRecipeProcessor {
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex));
if (recipe instanceof RecipeHandlerBase) {
Class<?> NEIRecipeBase = null;
try {
NEIRecipeBase =
Class.forName("cofh.thermalexpansion.plugins.nei.handlers.RecipeHandlerBase$NEIRecipeBase");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
if (NEIRecipeBase != null) {
Field secondaryInputField = ReflectionHelper.findField(NEIRecipeBase, "secondaryInput");
if (thermalNeiRecipeBaseClass != null) {
Field secondaryInputField = ReflectionHelper.findField(thermalNeiRecipeBaseClass, "secondaryInput");
PositionedStack secondaryInput = null;
try {
secondaryInput = (PositionedStack)
@@ -71,17 +75,11 @@ public class ThermalExpansionRecipeProcessor implements IRecipeProcessor {
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeOutputs.add(recipe.getResultStack(recipeIndex));
if (recipe instanceof RecipeHandlerBase) {
Class<?> NEIRecipeBase = null;
try {
NEIRecipeBase =
Class.forName("cofh.thermalexpansion.plugins.nei.handlers.RecipeHandlerBase$NEIRecipeBase");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
if (NEIRecipeBase != null) {
Field secondaryOutputField = ReflectionHelper.findField(NEIRecipeBase, "secondaryOutput");
if (thermalNeiRecipeBaseClass != null) {
Field secondaryOutputField =
ReflectionHelper.findField(thermalNeiRecipeBaseClass, "secondaryOutput");
Field secondaryOutputChanceField =
ReflectionHelper.findField(NEIRecipeBase, "secondaryOutputChance");
ReflectionHelper.findField(thermalNeiRecipeBaseClass, "secondaryOutputChance");
PositionedStack secondaryOutput = null;
int secondaryOutputChance = 0;
try {
@@ -24,6 +24,15 @@ public final class ItemUtils {
public static List<StackProcessor> transformItemBlacklist = getTransformItemBlacklist();
public static List<StackProcessor> transformItemPriorityList = getTransformItemPriorityList();
private static Class<?> GT_MetaGenerated_ToolClass;
static {
try {
GT_MetaGenerated_ToolClass = Class.forName("gregtech.api.items.GT_MetaGenerated_Tool");
} catch (ClassNotFoundException ignored) {
}
}
public static void reloadConfig() {
transformItemBlacklist = getTransformItemBlacklist();
transformItemPriorityList = getTransformItemPriorityList();
@@ -215,21 +224,18 @@ public final class ItemUtils {
public static void transformGTTool(ItemStack stack) {
if (!Loader.isModLoaded("gregtech")) return;
try {
Class<?> GTToolClazz = Class.forName("gregtech.api.items.GT_MetaGenerated_Tool");
if (GTToolClazz.isAssignableFrom(stack.getItem().getClass())) {
NBTTagCompound NBT = stack.getTagCompound();
if (NBT == null) {
NBT = new NBTTagCompound();
NBTTagCompound NBTToolStats = new NBTTagCompound();
NBTToolStats.setString("PrimaryMaterial", "Neutronium");
NBTToolStats.setString("SecondaryMaterial", "Neutronium");
NBTToolStats.setInteger("MaxDamage", 65536000);
NBT.setTag("GT.ToolStats", NBTToolStats);
stack.setTagCompound(NBT);
}
if (GT_MetaGenerated_ToolClass != null
&& GT_MetaGenerated_ToolClass.isAssignableFrom(stack.getItem().getClass())) {
NBTTagCompound NBT = stack.getTagCompound();
if (NBT == null) {
NBT = new NBTTagCompound();
NBTTagCompound NBTToolStats = new NBTTagCompound();
NBTToolStats.setString("PrimaryMaterial", "Neutronium");
NBTToolStats.setString("SecondaryMaterial", "Neutronium");
NBTToolStats.setInteger("MaxDamage", 65536000);
NBT.setTag("GT.ToolStats", NBTToolStats);
stack.setTagCompound(NBT);
}
} catch (ClassNotFoundException ignored) {
}
}
}