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
|
@ -28,45 +28,13 @@ package techreborn.api.generator;
|
|||
import net.minecraft.fluid.Fluid;
|
||||
import techreborn.utils.FluidUtils;
|
||||
|
||||
public class FluidGeneratorRecipe {
|
||||
private final EFluidGenerator generatorType;
|
||||
private final Fluid fluid;
|
||||
private final int energyPerMb;
|
||||
|
||||
public FluidGeneratorRecipe(Fluid fluid, int energyPerMb, EFluidGenerator generatorType) {
|
||||
this.fluid = fluid;
|
||||
this.energyPerMb = energyPerMb;
|
||||
this.generatorType = generatorType;
|
||||
}
|
||||
|
||||
public Fluid getFluid() {
|
||||
return fluid;
|
||||
}
|
||||
public record FluidGeneratorRecipe(Fluid fluid, int energyPerMb,
|
||||
EFluidGenerator generatorType) {
|
||||
|
||||
public int getEnergyPerBucket() {
|
||||
return energyPerMb * 1000;
|
||||
}
|
||||
|
||||
public EFluidGenerator getGeneratorType() {
|
||||
return generatorType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FluidGeneratorRecipe [generatorType=" + generatorType + ", fluid=" + fluid + ", energyPerMb="
|
||||
+ energyPerMb + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + energyPerMb;
|
||||
result = prime * result + ((fluid == null) ? 0 : fluid.hashCode());
|
||||
result = prime * result + ((generatorType == null) ? 0 : generatorType.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
|
|
|
@ -39,7 +39,7 @@ public class FluidGeneratorRecipeList {
|
|||
}
|
||||
|
||||
public boolean addRecipe(FluidGeneratorRecipe fluidGeneratorRecipe) {
|
||||
if (!this.getRecipeForFluid(fluidGeneratorRecipe.getFluid()).isPresent())
|
||||
if (!this.getRecipeForFluid(fluidGeneratorRecipe.fluid()).isPresent())
|
||||
return this.getRecipes().add(fluidGeneratorRecipe);
|
||||
return false;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class FluidGeneratorRecipeList {
|
|||
}
|
||||
|
||||
public Optional<FluidGeneratorRecipe> getRecipeForFluid(Fluid fluid) {
|
||||
return this.recipes.stream().filter(recipe -> FluidUtils.fluidEquals(recipe.getFluid(), fluid)).findAny();
|
||||
return this.recipes.stream().filter(recipe -> FluidUtils.fluidEquals(recipe.fluid(), fluid)).findAny();
|
||||
}
|
||||
|
||||
public HashSet<FluidGeneratorRecipe> getRecipes() {
|
||||
|
|
|
@ -66,8 +66,7 @@ public class BlastFurnaceRecipe extends RebornRecipe {
|
|||
|
||||
@Override
|
||||
public boolean canCraft(final BlockEntity blockEntity) {
|
||||
if (blockEntity instanceof IndustrialBlastFurnaceBlockEntity) {
|
||||
final IndustrialBlastFurnaceBlockEntity blastFurnace = (IndustrialBlastFurnaceBlockEntity) blockEntity;
|
||||
if (blockEntity instanceof final IndustrialBlastFurnaceBlockEntity blastFurnace) {
|
||||
return blastFurnace.getHeat() >= heat;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -73,8 +73,7 @@ public class FusionReactorRecipe extends RebornRecipe {
|
|||
|
||||
@Override
|
||||
public boolean canCraft(final BlockEntity blockEntity) {
|
||||
if (blockEntity instanceof FusionControlComputerBlockEntity) {
|
||||
final FusionControlComputerBlockEntity reactor = (FusionControlComputerBlockEntity) blockEntity;
|
||||
if (blockEntity instanceof final FusionControlComputerBlockEntity reactor) {
|
||||
return reactor.getSize() >= minSize;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue