Skip to content

Commit

Permalink
Remove capturing lambdas from active jetpack lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
pupnewfster committed Apr 7, 2024
1 parent 8004e0e commit 086b5b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/main/java/mekanism/common/item/ItemGaugeDropper.java
@@ -1,6 +1,7 @@
package mekanism.common.item;

import java.util.List;
import java.util.OptionalInt;
import mekanism.api.chemical.Chemical;
import mekanism.api.chemical.ChemicalStack;
import mekanism.api.chemical.IChemicalHandler;
Expand Down Expand Up @@ -44,7 +45,11 @@ public int getBarWidth(@NotNull ItemStack stack) {

@Override
public int getBarColor(@NotNull ItemStack stack) {
return FluidUtils.getRGBDurabilityForDisplay(stack).orElseGet(() -> ChemicalUtil.getRGBDurabilityForDisplay(stack));
OptionalInt color = FluidUtils.getRGBDurabilityForDisplay(stack);
if (color.isPresent()) {
return color.getAsInt();
}
return ChemicalUtil.getRGBDurabilityForDisplay(stack);
}

@NotNull
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/mekanism/common/item/interfaces/IJetpackItem.java
Expand Up @@ -90,12 +90,11 @@ static ItemStack getActiveJetpack(LivingEntity entity) {
if (entity.isPassenger()) {
return ItemStack.EMPTY;
}
return getJetpack(entity, stack -> {
if (stack.getItem() instanceof IJetpackItem jetpackItem && jetpackItem.canUseJetpack(stack)) {
return !(entity instanceof Player player) || !player.getCooldowns().isOnCooldown(stack.getItem());
}
return false;
});
ItemStack jetpack = getJetpack(entity, stack -> stack.getItem() instanceof IJetpackItem jetpackItem && jetpackItem.canUseJetpack(stack));
if (entity instanceof Player player && player.getCooldowns().isOnCooldown(jetpack.getItem())) {
return ItemStack.EMPTY;
}
return jetpack;
}

/**
Expand Down

0 comments on commit 086b5b8

Please sign in to comment.