Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename GT reflected classes #52

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraftforge.event.entity.living.LivingAttackEvent;

import com.brandon3055.draconicevolution.common.items.armor.CustomArmorHandler.ArmorSummery;
import com.brandon3055.draconicevolution.common.utills.LogHelper;

import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
Expand All @@ -15,30 +16,37 @@
*/
public class ModHelper {

private static boolean isTConInstalled;
private static boolean isAvaritiaInstalled;
private static final boolean isTConInstalled;
private static final boolean isAvaritiaInstalled;
// private static boolean isRotaryCraftInstalled;
private static boolean isGregTechInstalled;
private static final boolean isGregTechInstalled;
private static final boolean isBartworkdsInstalled;

private static Item cleaver;
private static Item avaritiaSword;
// private static Item bedrockSword;

private static Class bwores;
private static Class GTores;
private static Class<?> bwores;
private static Class<?> GTores;

static {
isTConInstalled = Loader.isModLoaded("TConstruct");
isAvaritiaInstalled = Loader.isModLoaded("Avaritia");
// isRotaryCraftInstalled = Loader.isModLoaded("RotaryCraft");
isGregTechInstalled = Loader.isModLoaded("gregtech");

isBartworkdsInstalled = Loader.isModLoaded("bartworks");
final String GT_ORE_CLASS = "gregtech.common.blocks.TileEntityOres";
final String BW_ORE_CLASS = "bartworks.system.material.BWMetaGeneratedOres";
if (isGregTechInstalled) try {
GTores = Class.forName("gregtech.common.blocks.GT_TileEntity_Ores");
} catch (ClassNotFoundException e) {}
if (Loader.isModLoaded("bartworks")) try {
bwores = Class.forName("com.github.bartimaeusnek.bartworks.system.material.BW_MetaGeneratedOreTE");
} catch (ClassNotFoundException e) {}
GTores = Class.forName(GT_ORE_CLASS);
} catch (ClassNotFoundException e) {
LogHelper.error("Couldn't reflect class " + GT_ORE_CLASS);
}
if (isBartworkdsInstalled) try {
bwores = Class.forName(BW_ORE_CLASS);
} catch (ClassNotFoundException e) {
LogHelper.error("Couldn't reflect class " + BW_ORE_CLASS);
}
}

public static boolean isHoldingCleaver(EntityPlayer player) {
Expand Down Expand Up @@ -102,7 +110,6 @@ else if (event.source.isUnblockable() || event.source.canHarmInCreative()) {
}

public static boolean isGregTechTileEntityOre(TileEntity te) {
return isGregTechInstalled && GTores.isInstance(te)
|| isGregTechInstalled && Loader.isModLoaded("bartworks") && bwores.isInstance(te);
return isGregTechInstalled && GTores.isInstance(te) || isBartworkdsInstalled && bwores.isInstance(te);
}
}