Skip to content

Commit

Permalink
cleaned up implicit mod deps
Browse files Browse the repository at this point in the history
  • Loading branch information
RecursivePineapple committed Jan 13, 2025
1 parent fe8a1a4 commit 9ec4d6b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.glodblock.github.inventory.AeItemStackHandler;
import com.glodblock.github.inventory.AeStackInventory;
import com.glodblock.github.inventory.AeStackInventoryImpl;
import com.glodblock.github.util.ModAndClassUtil;
import com.google.common.collect.ImmutableSet;

import appeng.api.AEApi;
Expand Down Expand Up @@ -171,16 +172,20 @@ private TickRateModulation doWork() {
if (batchSize > 0) {
IAEItemStack craftItem = requests.getCraftItem(i);

if (craftItem != null && ThaumicEnergisticsCrafting.isAspectStack(craftItem.getItemStack())) {
craftItem = ThaumicEnergisticsCrafting.convertAspectStack(craftItem);
if (ModAndClassUtil.ThE) {
if (craftItem != null && ThaumicEnergisticsCrafting.isAspectStack(craftItem.getItemStack())) {
craftItem = ThaumicEnergisticsCrafting.convertAspectStack(craftItem);
}
}

IAEItemStack aeItem = inv.findPrecise(craftItem);

long stackSize = aeItem == null ? 0 : aeItem.getStackSize();

if (aeItem != null && ThaumicEnergisticsCrafting.isAspectStack(aeItem.getItemStack())) {
stackSize = ThaumicEnergisticsCrafting.getEssentiaAmount(aeItem, grid);
if (ModAndClassUtil.ThE) {
if (aeItem != null && ThaumicEnergisticsCrafting.isAspectStack(aeItem.getItemStack())) {
stackSize = ThaumicEnergisticsCrafting.getEssentiaAmount(aeItem, grid);
}
}

boolean isDone = requests.isDone(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;

import com.glodblock.github.util.ModAndClassUtil;

import appeng.api.networking.IGrid;
import appeng.api.storage.data.IAEItemStack;
import appeng.util.item.AEItemStack;
Expand All @@ -32,14 +34,13 @@ public static void postInit() {
* an aspect.
*/
public static boolean isAspectStack(ItemStack stack) {
if (stack == null) return false;
if (!ModAndClassUtil.ThE || stack == null) return false;

return stack.getItem() == neiAddonAspect || stack.getItem() == thaumicEnergisticsAspect;
}

@Nullable
@Method(modid = "thaumicenergistics")
public static String getAspectName(ItemStack stack) {
private static @Nullable Aspect getAspect(ItemStack stack) {
if (stack == null) return null;

if (stack.getItem() == neiAddonAspect) {
Expand All @@ -49,28 +50,37 @@ public static String getAspectName(ItemStack stack) {
String aspect = aspects.getCompoundTagAt(0).getString("key");
if (aspect.isEmpty()) return null;

return aspect;
return Aspect.getAspect(aspect);
}

if (stack.getItem() == thaumicEnergisticsAspect) {
return ItemCraftingAspect.getAspect(stack).getTag();
return Aspect.getAspect(ItemCraftingAspect.getAspect(stack).getTag());
}

return null;
}

@Method(modid = "thaumicenergistics")
public static ItemStack getAspectStack(String aspectName, int stackSize) {
return ItemCraftingAspect.createStackForAspect(Aspect.getAspect(aspectName), stackSize);
private static ItemStack getAspectStack(Aspect aspect, int stackSize) {
return ItemCraftingAspect.createStackForAspect(aspect, stackSize);
}

/**
* Converts an aspect stack into a thaumic energistics stack.
*/
public static IAEItemStack convertAspectStack(IAEItemStack stack) {
if (ModAndClassUtil.ThE) {
return convertAspectStackImpl(stack);
} else {
return stack;
}
}

@Method(modid = "thaumicenergistics")
private static IAEItemStack convertAspectStackImpl(IAEItemStack stack) {
if (stack == null) return null;

String aspect = getAspectName(stack.getItemStack());
Aspect aspect = getAspect(stack.getItemStack());

if (aspect == null) return stack;

Expand All @@ -80,13 +90,17 @@ public static IAEItemStack convertAspectStack(IAEItemStack stack) {
/**
* Gets the amount of essentia stored in a grid for a given aspect preview.
*/
@Method(modid = "thaumicenergistics")
public static long getEssentiaAmount(IAEItemStack stack, IGrid grid) {
String aspectName = getAspectName(stack.getItemStack());

if (aspectName == null) return 0;
if (ModAndClassUtil.ThE) {
return getEssentiaAmountImpl(stack, grid);
} else {
return 0;
}
}

Aspect aspect = Aspect.getAspect(aspectName);
@Method(modid = "thaumicenergistics")
private static long getEssentiaAmountImpl(IAEItemStack stack, IGrid grid) {
Aspect aspect = getAspect(stack.getItemStack());

if (aspect == null) return 0;

Expand Down

0 comments on commit 9ec4d6b

Please sign in to comment.