cache some Loader.isModLoaded calls (#72)

This commit is contained in:
Alexdoru authored and GitHub committed 2023-02-08 21:11:39 +01:00
1 parent 131cdd6e6b
commit 531e33765e
3 files changed
+10 -12

No files matched your search

@@ -8,7 +8,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
@@ -66,6 +65,9 @@ public class ArmorProxyClient extends ArmorProxyCommon {
public static KnapsackInventory knapsack = new KnapsackInventory();
public static ArmorExtended armorExtended = new ArmorExtended();
private final boolean isRpghudLoaded = Loader.isModLoaded("rpghud");
private final boolean isTukmc_vzLoaded = Loader.isModLoaded("tukmc_Vz");
private final boolean isBorderlandsModLoaded = Loader.isModLoaded("borderlands");
@Override
public void preInit() {
@@ -236,8 +238,6 @@ public class ArmorProxyClient extends ArmorProxyCommon {
Random rand = new Random();
int updateCounter = 0;
GameSettings gs = Minecraft.getMinecraft().gameSettings;
@SubscribeEvent
public void goggleZoom(FOVUpdateEvent event) {
if (ArmorControls.zoom) {
@@ -259,11 +259,11 @@ public class ArmorProxyClient extends ArmorProxyCommon {
}
// uses different display, displays health correctly by itself.
if (Loader.isModLoaded("rpghud")) {
if (isRpghudLoaded) {
return;
}
if (Loader.isModLoaded("tukmc_Vz") && !Loader.isModLoaded("borderlands")) {
if (isTukmc_vzLoaded && !isBorderlandsModLoaded) {
// Loader check to avoid conflicting
// with a GUI mod (thanks Vazkii!)
return;
@@ -51,6 +51,7 @@ public class ArmorControls {
// boolean onStilts = false;
private final KeyBinding[] keys;
private boolean isNotEnoughKeysLoaded;
public ArmorControls() {
getVanillaKeyBindings();
@@ -64,7 +65,8 @@ public class ArmorControls {
ClientRegistry.registerKeyBinding(key);
}
}
if (Loader.isModLoaded("notenoughkeys")) {
isNotEnoughKeysLoaded = Loader.isModLoaded("notenoughkeys");
if (isNotEnoughKeysLoaded) {
Api.registerMod(TConstruct.modID, keyDescs);
}
// Add mc keys
@@ -80,7 +82,7 @@ public class ArmorControls {
@SubscribeEvent
public void keyEvent(KeyInputEvent event) {
if (!Loader.isModLoaded("notenoughkeys")) {
if (!isNotEnoughKeysLoaded) {
checkAndPerformKeyActions(null, false);
}
}
@@ -146,11 +146,7 @@ public class Crossbow extends ProjectileWeapon {
// remove loaded item
if (ammo.getItem() instanceof IAmmo) ((IAmmo) ammo.getItem()).consumeAmmo(1, ammo);
else {
if (Loader.isModLoaded("battlegear2")) {
player.inventory.consumeInventoryItem(ammo.getItem());
} else {
player.inventory.consumeInventoryItem(ammo.getItem());
}
player.inventory.consumeInventoryItem(ammo.getItem());
}
playReloadSound(world, player, weapon, ammo);