mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Java16 Sonar Changes - 5
This commit is contained in:
parent
0f6b6b244c
commit
9f4cb828cb
@ -43,9 +43,7 @@ public class Multimeter extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
if (e.getClickedBlock().isPresent() && block.isPresent()) {
|
||||
SlimefunItem item = block.get();
|
||||
|
||||
if (item instanceof EnergyNetComponent) {
|
||||
EnergyNetComponent component = (EnergyNetComponent) item;
|
||||
|
||||
if (item instanceof EnergyNetComponent component) {
|
||||
if (component.isChargeable()) {
|
||||
e.cancel();
|
||||
|
||||
|
@ -67,8 +67,8 @@ public class SolarHelmet extends SlimefunItem {
|
||||
private void recharge(@Nullable ItemStack item) {
|
||||
SlimefunItem sfItem = SlimefunItem.getByItem(item);
|
||||
|
||||
if (sfItem instanceof Rechargeable) {
|
||||
((Rechargeable) sfItem).addItemCharge(item, charge.getValue().floatValue());
|
||||
if (sfItem instanceof Rechargeable rechargeable) {
|
||||
rechargeable.addItemCharge(item, charge.getValue().floatValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,10 +53,10 @@ public class ChargingBench extends AContainer {
|
||||
private boolean charge(Block b, BlockMenu inv, int slot, ItemStack item) {
|
||||
SlimefunItem sfItem = SlimefunItem.getByItem(item);
|
||||
|
||||
if (sfItem instanceof Rechargeable) {
|
||||
if (sfItem instanceof Rechargeable rechargeable) {
|
||||
float charge = getEnergyConsumption() / 2F;
|
||||
|
||||
if (((Rechargeable) sfItem).addItemCharge(item, charge)) {
|
||||
if (rechargeable.addItemCharge(item, charge)) {
|
||||
removeCharge(b.getLocation(), getEnergyConsumption());
|
||||
} else if (inv.fits(item, getOutputSlots())) {
|
||||
inv.pushItem(item, getOutputSlots());
|
||||
|
@ -37,8 +37,8 @@ public class ElectricFurnace extends AContainer implements NotHopperable {
|
||||
for (FurnaceRecipe recipe : snapshot.getRecipes(FurnaceRecipe.class)) {
|
||||
RecipeChoice choice = recipe.getInputChoice();
|
||||
|
||||
if (choice instanceof MaterialChoice) {
|
||||
for (Material input : ((MaterialChoice) choice).getChoices()) {
|
||||
if (choice instanceof MaterialChoice materialChoice) {
|
||||
for (Material input : materialChoice.getChoices()) {
|
||||
registerRecipe(4, new ItemStack[] { new ItemStack(input) }, new ItemStack[] { recipe.getResult() });
|
||||
}
|
||||
}
|
||||
|
@ -227,16 +227,14 @@ public class FluidPump extends SimpleSlimefunItem<BlockTicker> implements Invent
|
||||
}
|
||||
|
||||
private @Nonnull ItemStack getFilledBucket(@Nonnull Block fluid) {
|
||||
switch (fluid.getType()) {
|
||||
case LAVA:
|
||||
return new ItemStack(Material.LAVA_BUCKET);
|
||||
case WATER:
|
||||
case BUBBLE_COLUMN:
|
||||
return new ItemStack(Material.WATER_BUCKET);
|
||||
default:
|
||||
return switch (fluid.getType()) {
|
||||
case LAVA -> new ItemStack(Material.LAVA_BUCKET);
|
||||
case WATER,
|
||||
BUBBLE_COLUMN -> new ItemStack(Material.WATER_BUCKET);
|
||||
default ->
|
||||
// Fallback for any new liquids
|
||||
return new ItemStack(Material.BUCKET);
|
||||
}
|
||||
new ItemStack(Material.BUCKET);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -251,9 +249,8 @@ public class FluidPump extends SimpleSlimefunItem<BlockTicker> implements Invent
|
||||
if (block.isLiquid()) {
|
||||
BlockData data = block.getBlockData();
|
||||
|
||||
if (data instanceof Levelled) {
|
||||
if (data instanceof Levelled levelled) {
|
||||
// Check if this is a full block.
|
||||
Levelled levelled = (Levelled) data;
|
||||
return levelled.getLevel() == 0;
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class AnimalGrowthAccelerator extends AbstractGrowthAccelerator {
|
||||
}
|
||||
|
||||
private boolean isReadyToGrow(Entity n) {
|
||||
return n instanceof Ageable && n.isValid() && !((Ageable) n).isAdult();
|
||||
return n instanceof Ageable ageable && n.isValid() && !ageable.isAdult();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -128,9 +128,7 @@ public class AutoBreeder extends SlimefunItem implements InventoryBlock, EnergyN
|
||||
}
|
||||
|
||||
private boolean canBreed(@Nonnull Entity n) {
|
||||
if (n.isValid() && n instanceof Animals) {
|
||||
Animals animal = (Animals) n;
|
||||
|
||||
if (n.isValid() && n instanceof Animals animal) {
|
||||
return animal.isAdult() && animal.canBreed() && !animal.isLoveMode();
|
||||
}
|
||||
|
||||
|
@ -75,8 +75,8 @@ public class ProduceCollector extends AContainer implements RecipeDisplayItem {
|
||||
|
||||
// Mushroom Stew from Mooshrooms
|
||||
addProduce(new AnimalProduce(new ItemStack(Material.BOWL), new ItemStack(Material.MUSHROOM_STEW), n -> {
|
||||
if (n instanceof MushroomCow) {
|
||||
return ((MushroomCow) n).isAdult();
|
||||
if (n instanceof MushroomCow mushroomCow) {
|
||||
return mushroomCow.isAdult();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -158,8 +158,8 @@ public class ProduceCollector extends AContainer implements RecipeDisplayItem {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
private boolean isValidAnimal(Entity n, Predicate<LivingEntity> predicate) {
|
||||
if (n instanceof LivingEntity) {
|
||||
return predicate.test((LivingEntity) n);
|
||||
if (n instanceof LivingEntity livingEntity) {
|
||||
return predicate.test(livingEntity);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -44,8 +44,8 @@ public abstract class NetherStarReactor extends Reactor {
|
||||
public void extraTick(@Nonnull Location l) {
|
||||
Slimefun.runSync(() -> {
|
||||
for (Entity entity : l.getWorld().getNearbyEntities(l, 5, 5, 5, n -> n instanceof LivingEntity && n.isValid())) {
|
||||
if (entity instanceof LivingEntity) {
|
||||
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 60, 1));
|
||||
if (entity instanceof LivingEntity livingEntity) {
|
||||
livingEntity.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 60, 1));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user