Skip to content

Commit 506644f

Browse files
committed
Fix unbreakable upgrade
1 parent cc13697 commit 506644f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/main/java/mrbysco/constructionstick/items/stick/ItemStick.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public int remainingDurability(ItemStack stack) {
9898
}
9999

100100
public void hurtItem(ItemStack stack, int amount, LivingEntity entity, EquipmentSlot slot) {
101-
if (stack.has(ModDataComponents.BATTERY)) {
101+
if (stack.has(ModDataComponents.BATTERY_ENABLED)) {
102102
if (entity.hasInfiniteMaterials()) return;
103103
IEnergyStorage storage = stack.getCapability(Capabilities.EnergyStorage.ITEM);
104104
if (storage != null) {
@@ -150,7 +150,7 @@ public void appendHoverText(@NotNull ItemStack itemstack, TooltipContext context
150150
StickUpgradesSelectable<IStickTemplate> upgrades = options.upgrades;
151151
lines.add(Component.translatable(langTooltip + "blocks", limit).withStyle(ChatFormatting.GRAY));
152152

153-
if (itemstack.has(ModDataComponents.BATTERY)) {
153+
if (itemstack.has(ModDataComponents.BATTERY_ENABLED)) {
154154
IEnergyStorage storage = itemstack.getCapability(Capabilities.EnergyStorage.ITEM);
155155
if (storage != null) {
156156
int energy = storage.getEnergyStored();

src/main/java/mrbysco/constructionstick/items/stick/ItemStickBasic.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public boolean isBarVisible(ItemStack stack) {
2828

2929
@Override
3030
public int getBarWidth(ItemStack stack) {
31-
if (stack.has(ModDataComponents.BATTERY)) {
31+
if (stack.has(ModDataComponents.BATTERY_ENABLED)) {
3232
IEnergyStorage storage = stack.getCapability(Capabilities.EnergyStorage.ITEM);
3333
if (storage != null) {
3434
return Math.round((13.0F / storage.getMaxEnergyStored() * storage.getEnergyStored()));
@@ -39,7 +39,7 @@ public int getBarWidth(ItemStack stack) {
3939

4040
@Override
4141
public int getBarColor(ItemStack stack) {
42-
if (stack.has(ModDataComponents.BATTERY)) {
42+
if (stack.has(ModDataComponents.BATTERY_ENABLED)) {
4343
return 0x971607;
4444
}
4545
return super.getBarColor(stack);
@@ -53,12 +53,14 @@ public int getMaxDamage(ItemStack stack) {
5353
@Override
5454
public int remainingDurability(ItemStack stack) {
5555
if (stack.has(ModDataComponents.UNBREAKABLE)) {
56+
return Integer.MAX_VALUE;
57+
}
58+
if (stack.has(ModDataComponents.BATTERY_ENABLED)) {
5659
IEnergyStorage storage = stack.getCapability(Capabilities.EnergyStorage.ITEM);
5760
if (storage != null) {
5861
int usage = ConstructionConfig.getStickProperties(this).getBatteryUsage();
5962
return storage.getEnergyStored() / usage;
6063
}
61-
return 0;
6264
}
6365
return stack.getMaxDamage() - stack.getDamageValue();
6466
}

0 commit comments

Comments
 (0)