Implement item bar visibility config (#125)

* Implement item bar visibility config

* Forgot about spotless

* Recommit changed files + added magnet, cap bank, and staff bar hiding
This commit is contained in:
Caedis authored and GitHub committed 2023-06-04 22:09:59 +02:00
1 parent 2629076937
commit 5fdd24293a
5 files changed
+37 -10

No files matched your search

@@ -321,6 +321,8 @@ public final class Config {
public static boolean addFuelTooltipsToAllFluidContainers = true;
public static boolean addFurnaceFuelTootip = true;
public static boolean addDurabilityTootip = true;
public static boolean renderDurabilityBar = true;
public static boolean renderChargeBar = true;
public static int farmContinuousEnergyUseRF = 40;
public static int farmActionEnergyUseRF = 500;
@@ -1916,6 +1918,16 @@ public final class Config {
"addFurnaceFuelTootip",
addFuelTooltipsToAllFluidContainers,
"If true, adds burn duration tooltips to furnace fuels").getBoolean(addFurnaceFuelTootip);
renderChargeBar = config.get(
sectionPersonal.name,
"renderChargeBar",
renderChargeBar,
"If true, render the bar when an item has RF").getBoolean(renderChargeBar);
renderDurabilityBar = config.get(
sectionPersonal.name,
"renderDurabilityBar",
renderDurabilityBar,
"If true, render the bar when an item is damaged").getBoolean(renderDurabilityBar);
farmContinuousEnergyUseRF = config.get(
sectionFarm.name,
@@ -236,4 +236,9 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP
public boolean canUnequip(ItemStack itemstack, EntityLivingBase player) {
return true;
}
@Override
public boolean showDurabilityBar(ItemStack stack) {
return Config.renderDurabilityBar && super.showDurabilityBar(stack);
}
}
@@ -15,6 +15,7 @@ import com.enderio.core.client.render.RenderUtil;
import com.enderio.core.common.vecmath.Vector4f;
import cofh.api.energy.IEnergyContainerItem;
import crazypants.enderio.config.Config;
import crazypants.enderio.item.darksteel.upgrade.EnergyUpgrade;
public class PoweredItemRenderer implements IItemRenderer {
@@ -44,26 +45,29 @@ public class PoweredItemRenderer implements IItemRenderer {
ri.renderItemIntoGUI(mc.fontRenderer, mc.getTextureManager(), item, 0, 0, true);
GL11.glDisable(GL11.GL_LIGHTING);
if (isJustCrafted(item)) {
if (isJustCrafted(item) || (!Config.renderChargeBar && !Config.renderDurabilityBar)) {
return;
}
boolean hasEnergyUpgrade = EnergyUpgrade.loadFromItem(item) != null;
int y = hasEnergyUpgrade ? 12 : 13;
int bgH = hasEnergyUpgrade ? 4 : 2;
int y = (Config.renderDurabilityBar ^ Config.renderChargeBar) || !hasEnergyUpgrade ? 13 : 12;
int bgH = (Config.renderDurabilityBar ^ Config.renderChargeBar) || !hasEnergyUpgrade ? 2 : 4;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
RenderUtil.renderQuad2D(2, y, 0, 13, bgH, ColorUtil.getRGB(Color.black));
double maxDam = item.getMaxDamage();
double dispDamage = item.getItemDamageForDisplay();
y = hasEnergyUpgrade ? 14 : 13;
renderBar(y, maxDam, dispDamage, Color.green, Color.red);
double maxDam, dispDamage;
if (Config.renderDurabilityBar) {
maxDam = item.getMaxDamage();
dispDamage = item.getItemDamageForDisplay();
y = Config.renderChargeBar && hasEnergyUpgrade ? 14 : 13;
renderBar(y, maxDam, dispDamage, Color.green, Color.red);
}
if (hasEnergyUpgrade) {
if (Config.renderChargeBar && hasEnergyUpgrade) {
IEnergyContainerItem armor = (IEnergyContainerItem) item.getItem();
maxDam = armor.getMaxEnergyStored(item);
dispDamage = armor.getEnergyStored(item);
y = 12;
y = Config.renderDurabilityBar ? 12 : 13;
Color color = new Color(0x2D, 0xCE, 0xFA); // electric blue
renderBar2(y, maxDam, maxDam - dispDamage, color, color);
}
@@ -7,6 +7,7 @@ import net.minecraft.item.ItemStack;
import cofh.api.energy.IEnergyContainerItem;
import crazypants.enderio.EnderIO;
import crazypants.enderio.EnderIOTab;
import crazypants.enderio.config.Config;
import crazypants.enderio.power.PowerHandlerUtil;
public class BlockItemCapBank extends ItemBlock implements IEnergyContainerItem {
@@ -42,7 +43,7 @@ public class BlockItemCapBank extends ItemBlock implements IEnergyContainerItem
@Override
public boolean showDurabilityBar(ItemStack itemStack) {
return !CapBankType.getTypeFromMeta(itemStack.getItemDamage()).isCreative();
return Config.renderDurabilityBar && !CapBankType.getTypeFromMeta(itemStack.getItemDamage()).isCreative();
}
@Override
@@ -177,4 +177,9 @@ public class ItemTravelStaff extends ItemEnergyContainer implements IItemOfTrave
public boolean isFull3D() {
return true;
}
@Override
public boolean showDurabilityBar(ItemStack stack) {
return Config.renderDurabilityBar && super.showDurabilityBar(stack);
}
}