Use modern java features where we can, optimise imports.
This commit is contained in:
parent
52e4767247
commit
31e7b357dc
135 changed files with 342 additions and 794 deletions
|
@ -64,12 +64,11 @@ public class FluidUtils {
|
|||
ItemStack outputStack = inventory.getStack(outputSlot);
|
||||
|
||||
if (inputStack.isEmpty()) return false;
|
||||
if (!(inputStack.getItem() instanceof ItemFluidInfo)) return false;
|
||||
if (!(inputStack.getItem() instanceof ItemFluidInfo itemFluidInfo)) return false;
|
||||
if (FluidUtils.isContainerEmpty(inputStack)) return false;
|
||||
if (outputStack.getCount() >= outputStack.getMaxCount()) return false;
|
||||
if (!outputStack.isEmpty() && !FluidUtils.isContainerEmpty(outputStack)) return false;
|
||||
|
||||
ItemFluidInfo itemFluidInfo = (ItemFluidInfo) inputStack.getItem();
|
||||
if (!outputStack.isEmpty() && !outputStack.isItemEqual(itemFluidInfo.getEmpty())) return false;
|
||||
|
||||
FluidInstance tankFluidInstance = tank.getFluidInstance(null);
|
||||
|
@ -109,11 +108,9 @@ public class FluidUtils {
|
|||
|
||||
if (!outputStack.isEmpty()) {
|
||||
if (outputStack.getCount() >= outputStack.getMaxCount()) return false;
|
||||
if (!(outputStack.getItem() instanceof ItemFluidInfo)) return false;
|
||||
if (!(outputStack.getItem() instanceof ItemFluidInfo outputFluidInfo)) return false;
|
||||
if (!outputStack.isItemEqual(itemFluidInfo.getEmpty())) return false;
|
||||
|
||||
ItemFluidInfo outputFluidInfo = (ItemFluidInfo) outputStack.getItem();
|
||||
|
||||
if (outputFluidInfo.getFluid(outputStack) != sourceFluid.getFluid()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -138,9 +135,9 @@ public class FluidUtils {
|
|||
public static boolean isContainerEmpty(ItemStack stack) {
|
||||
if (stack.isEmpty())
|
||||
return false;
|
||||
if (!(stack.getItem() instanceof ItemFluidInfo))
|
||||
return false;
|
||||
ItemFluidInfo itemFluidInfo = (ItemFluidInfo) stack.getItem();
|
||||
return itemFluidInfo.getFluid(stack) == Fluids.EMPTY;
|
||||
if (stack.getItem() instanceof ItemFluidInfo itemFluidInfo)
|
||||
return itemFluidInfo.getFluid(stack) == Fluids.EMPTY;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,9 +28,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.items.DynamicCellItem;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
package techreborn.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
@ -72,9 +71,9 @@ public class TagRemapper {
|
|||
final char quote = '"';
|
||||
return path -> {
|
||||
try {
|
||||
String recipe = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
|
||||
String recipe = Files.readString(path);
|
||||
recipe = recipe.replaceAll(quote + rename.getOldTagName() + quote, quote + rename.getNewTagName() + quote);
|
||||
Files.write(path, recipe.getBytes(StandardCharsets.UTF_8));
|
||||
Files.writeString(path, recipe);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
@ -52,19 +52,13 @@ public class ToolTipAssistUtils {
|
|||
boolean shouldStackCalculate = count > 1;
|
||||
|
||||
switch (upgradeType) {
|
||||
case OVERCLOCKER:
|
||||
case OVERCLOCKER -> {
|
||||
tips.add(getPositive(I18n.translate("techreborn.tooltip.upgrade.speed_increase"), calculateValue(TechRebornConfig.overclockerSpeed * 100, count, shiftHeld), "%"));
|
||||
tips.add(getNegative(I18n.translate("techreborn.tooltip.upgrade.energy_increase"), calculateValue(TechRebornConfig.overclockerPower * 100, count, shiftHeld), "%"));
|
||||
break;
|
||||
case TRANSFORMER:
|
||||
shouldStackCalculate = false;
|
||||
break;
|
||||
case ENERGY_STORAGE:
|
||||
tips.add(getPositive(I18n.translate("techreborn.tooltip.upgrade.storage_increase"), calculateValue(TechRebornConfig.energyStoragePower, count, shiftHeld), " E"));
|
||||
break;
|
||||
case SUPERCONDUCTOR:
|
||||
tips.add(getPositive(I18n.translate("techreborn.tooltip.upgrade.flow_increase"), calculateValue(Math.pow(2, (TechRebornConfig.superConductorCount + 2)) * 100, count, shiftHeld), "%"));
|
||||
break;
|
||||
}
|
||||
case TRANSFORMER -> shouldStackCalculate = false;
|
||||
case ENERGY_STORAGE -> tips.add(getPositive(I18n.translate("techreborn.tooltip.upgrade.storage_increase"), calculateValue(TechRebornConfig.energyStoragePower, count, shiftHeld), " E"));
|
||||
case SUPERCONDUCTOR -> tips.add(getPositive(I18n.translate("techreborn.tooltip.upgrade.flow_increase"), calculateValue(Math.pow(2, (TechRebornConfig.superConductorCount + 2)) * 100, count, shiftHeld), "%"));
|
||||
}
|
||||
|
||||
// Add reminder that they can use shift to calculate the entire stack
|
||||
|
|
|
@ -36,9 +36,9 @@ import net.minecraft.util.hit.HitResult;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import team.reborn.energy.Energy;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
|
@ -91,11 +91,10 @@ public class ToolsUtil {
|
|||
* @return Set of BlockPos to process by tool block break logic
|
||||
*/
|
||||
public static Set<BlockPos> getAOEMiningBlocks(World worldIn, BlockPos pos, @Nullable LivingEntity entityLiving, int radius, boolean placeDummyBlocks) {
|
||||
if (!(entityLiving instanceof PlayerEntity)) {
|
||||
if (!(entityLiving instanceof PlayerEntity playerIn)) {
|
||||
return ImmutableSet.of();
|
||||
}
|
||||
Set<BlockPos> targetBlocks = new HashSet<>();
|
||||
PlayerEntity playerIn = (PlayerEntity) entityLiving;
|
||||
|
||||
if (placeDummyBlocks) {
|
||||
//Put a dirt block down to raytrace with to stop it raytracing past the intended block
|
||||
|
@ -133,30 +132,30 @@ public class ToolsUtil {
|
|||
int maxZ = 0;
|
||||
|
||||
switch (playerDirection) {
|
||||
case SOUTH:
|
||||
case SOUTH -> {
|
||||
minZ = -1;
|
||||
maxZ = 1 + (radius - 1) * 2;
|
||||
minX = -radius;
|
||||
maxX = radius;
|
||||
break;
|
||||
case NORTH:
|
||||
}
|
||||
case NORTH -> {
|
||||
minZ = -1 - (radius - 1) * 2;
|
||||
maxZ = 1;
|
||||
minX = -radius;
|
||||
maxX = radius;
|
||||
break;
|
||||
case WEST:
|
||||
}
|
||||
case WEST -> {
|
||||
minZ = -radius;
|
||||
maxZ = radius;
|
||||
minX = -1 - (radius - 1) * 2;
|
||||
maxX = 1;
|
||||
break;
|
||||
case EAST:
|
||||
}
|
||||
case EAST -> {
|
||||
minZ = -radius;
|
||||
maxZ = radius;
|
||||
minX = -1;
|
||||
maxX = 1 + (radius - 1) * 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue