Refactor and import cleanup (Excluding network PR changed files)

This commit is contained in:
Justin Vitale 2020-07-09 23:04:42 +10:00
parent a36a0e6f4a
commit c4ef977f16
165 changed files with 1572 additions and 1625 deletions

View file

@ -47,63 +47,63 @@ import java.util.LinkedList;
import java.util.List;
public class MachineRecipeCategory<R extends RebornRecipe> implements RecipeCategory<MachineRecipeDisplay<R>> {
private final RebornRecipeType<R> rebornRecipeType;
private int recipeLines;
private final int recipeLines;
MachineRecipeCategory(RebornRecipeType<R> rebornRecipeType) {
this(rebornRecipeType, 2);
}
MachineRecipeCategory(RebornRecipeType<R> rebornRecipeType, int lines) {
this.rebornRecipeType = rebornRecipeType;
this.recipeLines = lines;
}
@Override
public Identifier getIdentifier() {
return rebornRecipeType.getName();
}
@Override
public String getCategoryName() {
return I18n.translate(rebornRecipeType.getName().toString());
}
@Override
public EntryStack getLogo() {
return EntryStack.create(ReiPlugin.iconMap.getOrDefault(rebornRecipeType, () -> Items.DIAMOND_SHOVEL));
}
@Override
public RecipeEntry getSimpleRenderer(MachineRecipeDisplay<R> recipe) {
return SimpleRecipeEntry.create(Collections.singletonList(recipe.getInputEntries().get(0)), recipe.getOutputEntries());
}
@Override
public List<Widget> setupDisplay(MachineRecipeDisplay<R> machineRecipe, Rectangle bounds) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - recipeLines * 12 - 1);
List<Widget> widgets = new LinkedList<>();
widgets.add(Widgets.createRecipeBase(bounds));
widgets.add(Widgets.createArrow(new Point(startPoint.x + 26, startPoint.y + 1)).animationDurationTicks(machineRecipe.getTime()));
int i = 0;
for (List<EntryStack> inputs : machineRecipe.getInputEntries()) {
widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1 + (i++ * 20))).entries(inputs).markInput());
}
Text energyPerTick = new TranslatableText("techreborn.jei.recipe.running.cost", "E", machineRecipe.getEnergy());
Label costLabel;
widgets.add(costLabel = Widgets.createLabel(new Point(startPoint.x + 1, startPoint.y + 1 + (i++ * 20)), energyPerTick));
costLabel.shadow(false);
costLabel.color(0xFF404040, 0xFFBBBBBB);
i = 0;
for (EntryStack outputs : machineRecipe.getOutputEntries()) {
widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 1 + (i++ * 20))).entry(outputs).markInput());
}
int heat = machineRecipe.getHeat();
if (heat > 0) {
Text neededHeat = new LiteralText(String.valueOf(heat)).append(" ").append(new TranslatableText("techreborn.jei.recipe.heat"));
@ -112,10 +112,10 @@ public class MachineRecipeCategory<R extends RebornRecipe> implements RecipeCate
heatLabel.shadow(false);
heatLabel.color(0xFF404040, 0xFFBBBBBB);
}
return widgets;
}
@Override
public int getDisplayHeight() {
if (recipeLines == 1) {
@ -127,5 +127,5 @@ public class MachineRecipeCategory<R extends RebornRecipe> implements RecipeCate
}
return 60;
}
}

View file

@ -38,15 +38,15 @@ import java.util.List;
import java.util.Optional;
public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDisplay {
private final R recipe;
private List<List<EntryStack>> inputs;
private List<EntryStack> outputs;
private final List<List<EntryStack>> inputs;
private final List<EntryStack> outputs;
private int energy = 0;
private int heat = 0;
private int time = 0;
private FluidInstance fluidInstance = null;
public MachineRecipeDisplay(R recipe) {
this.recipe = recipe;
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> CollectionUtils.map(ing.getPreviewStacks(), RebornEntryStack::create));
@ -66,43 +66,43 @@ public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDispl
for (EntryStack stack : outputs)
ReiPlugin.applyCellEntry(stack);
}
public int getEnergy() {
return energy;
}
public int getHeat() {
return heat;
}
public int getTime() {
return time;
}
public FluidInstance getFluidInstance() {
return fluidInstance;
}
@Override
public Optional<Identifier> getRecipeLocation() {
return Optional.ofNullable(recipe).map(RebornRecipe::getId);
}
@Override
public List<List<EntryStack>> getInputEntries() {
return inputs;
}
@Override
public List<List<EntryStack>> getRequiredEntries() {
return inputs;
}
@Override
public List<EntryStack> getOutputEntries() {
return outputs;
}
@Override
public Identifier getRecipeCategory() {
return recipe.getRebornRecipeType().getName();

View file

@ -60,11 +60,11 @@ import java.util.function.Function;
import java.util.function.Predicate;
public class ReiPlugin implements REIPluginV0 {
public static final Identifier PLUGIN = new Identifier(TechReborn.MOD_ID, "techreborn_plugin");
public static final Map<RebornRecipeType<?>, ItemConvertible> iconMap = new HashMap<>();
public ReiPlugin() {
iconMap.put(ModRecipes.ALLOY_SMELTER, Machine.ALLOY_SMELTER);
iconMap.put(ModRecipes.ASSEMBLING_MACHINE, Machine.ASSEMBLY_MACHINE);
@ -87,12 +87,12 @@ public class ReiPlugin implements REIPluginV0 {
iconMap.put(ModRecipes.VACUUM_FREEZER, Machine.VACUUM_FREEZER);
iconMap.put(ModRecipes.WIRE_MILL, Machine.WIRE_MILL);
}
@Override
public Identifier getPluginIdentifier() {
return PLUGIN;
}
@Override
public void registerPluginCategories(RecipeHelper recipeHelper) {
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.ALLOY_SMELTER));
@ -115,25 +115,25 @@ public class ReiPlugin implements REIPluginV0 {
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.SOLID_CANNING_MACHINE));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.VACUUM_FREEZER, 1));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.WIRE_MILL, 1));
recipeHelper.registerCategory(new FluidGeneratorRecipeCategory(Machine.THERMAL_GENERATOR));
recipeHelper.registerCategory(new FluidGeneratorRecipeCategory(Machine.GAS_TURBINE));
recipeHelper.registerCategory(new FluidGeneratorRecipeCategory(Machine.DIESEL_GENERATOR));
recipeHelper.registerCategory(new FluidGeneratorRecipeCategory(Machine.SEMI_FLUID_GENERATOR));
recipeHelper.registerCategory(new FluidGeneratorRecipeCategory(Machine.PLASMA_GENERATOR));
}
@Override
public void registerRecipeDisplays(RecipeHelper recipeHelper) {
RecipeManager.getRecipeTypes("techreborn").forEach(rebornRecipeType -> registerMachineRecipe(recipeHelper, rebornRecipeType));
registerFluidGeneratorDisplays(recipeHelper, EFluidGenerator.THERMAL, Machine.THERMAL_GENERATOR);
registerFluidGeneratorDisplays(recipeHelper, EFluidGenerator.GAS, Machine.GAS_TURBINE);
registerFluidGeneratorDisplays(recipeHelper, EFluidGenerator.DIESEL, Machine.DIESEL_GENERATOR);
registerFluidGeneratorDisplays(recipeHelper, EFluidGenerator.SEMIFLUID, Machine.SEMI_FLUID_GENERATOR);
registerFluidGeneratorDisplays(recipeHelper, EFluidGenerator.PLASMA, Machine.PLASMA_GENERATOR);
}
@Override
public void registerOthers(RecipeHelper recipeHelper) {
recipeHelper.registerWorkingStations(ModRecipes.ALLOY_SMELTER.getName(), EntryStack.create(Machine.ALLOY_SMELTER), EntryStack.create(Machine.IRON_ALLOY_FURNACE));
@ -161,7 +161,7 @@ public class ReiPlugin implements REIPluginV0 {
recipeHelper.registerWorkingStations(new Identifier(TechReborn.MOD_ID, Machine.SEMI_FLUID_GENERATOR.name), EntryStack.create(Machine.SEMI_FLUID_GENERATOR));
recipeHelper.registerWorkingStations(new Identifier(TechReborn.MOD_ID, Machine.PLASMA_GENERATOR.name), EntryStack.create(Machine.PLASMA_GENERATOR));
}
@Override
public void postRegister() {
// Alright we are going to apply check tags to cells, this should not take long at all.
@ -169,38 +169,38 @@ public class ReiPlugin implements REIPluginV0 {
for (EntryStack stack : EntryRegistry.getInstance().getStacksList())
applyCellEntry(stack);
}
public static void applyCellEntry(EntryStack stack) {
// getItem can be null but this works
if (stack.getItem() == TRContent.CELL)
stack.addSetting(EntryStack.Settings.CHECK_TAGS, EntryStack.Settings.TRUE);
}
private void registerFluidGeneratorDisplays(RecipeHelper recipeHelper, EFluidGenerator generator, Machine machine) {
Identifier identifier = new Identifier(TechReborn.MOD_ID, machine.name);
GeneratorRecipeHelper.getFluidRecipesForGenerator(generator).getRecipes().forEach(recipe -> {
recipeHelper.registerDisplay(new FluidGeneratorRecipeDisplay(recipe, identifier));
});
}
private <R extends RebornRecipe> void registerMachineRecipe(RecipeHelper recipeHelper, RebornRecipeType<R> recipeType) {
Function<R, RecipeDisplay> recipeDisplay = r -> new MachineRecipeDisplay<>((RebornRecipe) r);
if (recipeType == ModRecipes.ROLLING_MACHINE) {
recipeDisplay = r -> {
RollingMachineRecipe rollingMachineRecipe = (RollingMachineRecipe) r;
return new RollingMachineDisplay(rollingMachineRecipe.getShapedRecipe());
};
}
if (recipeType == ModRecipes.FLUID_REPLICATOR) {
recipeDisplay = r -> {
FluidReplicatorRecipe recipe = (FluidReplicatorRecipe) r;
return new FluidReplicatorRecipeDisplay(recipe);
};
}
recipeHelper.registerRecipes(recipeType.getName(), (Predicate<Recipe>) recipe -> {
if (recipe instanceof RebornRecipe) {
return ((RebornRecipe) recipe).getRebornRecipeType() == recipeType;
@ -230,7 +230,7 @@ public class ReiPlugin implements REIPluginV0 {
}
if (height > 0) {
int width = 20;
return Collections.singletonList(new Rectangle(guiBase.getGuiLeft() - width, guiBase.getGuiTop() + 8, width , height));
return Collections.singletonList(new Rectangle(guiBase.getGuiLeft() - width, guiBase.getGuiTop() + 8, width, height));
}
}
return Collections.emptyList();

View file

@ -42,54 +42,54 @@ import java.util.LinkedList;
import java.util.List;
public class FluidGeneratorRecipeCategory implements RecipeCategory<FluidGeneratorRecipeDisplay> {
private TRContent.Machine generator;
private Identifier identifier;
private final TRContent.Machine generator;
private final Identifier identifier;
public FluidGeneratorRecipeCategory(TRContent.Machine generator) {
this.generator = generator;
this.identifier = new Identifier(TechReborn.MOD_ID, generator.name);
}
@Override
public Identifier getIdentifier() {
return identifier;
}
@Override
public String getCategoryName() {
return I18n.translate(identifier.toString());
}
@Override
public EntryStack getLogo() {
return EntryStack.create(generator);
}
@Override
public List<Widget> setupDisplay(FluidGeneratorRecipeDisplay machineRecipe, Rectangle bounds) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 13);
List<Widget> widgets = new LinkedList<>();
widgets.add(Widgets.createRecipeBase(bounds));
widgets.add(Widgets.createArrow(new Point(startPoint.x + 26, startPoint.y + 1)).animationDurationMS(1000.0));
for (List<EntryStack> inputs : machineRecipe.getInputEntries()) {
widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(inputs).markInput());
}
Text energyPerTick = new TranslatableText("techreborn.jei.recipe.generator.total", machineRecipe.getTotalEnergy());
Label costLabel;
widgets.add(costLabel = Widgets.createLabel(new Point(bounds.getCenterX(), startPoint.y + 20), energyPerTick));
costLabel.shadow(false);
costLabel.color(0xFF404040, 0xFFBBBBBB);
return widgets;
}
@Override
public int getDisplayHeight() {
return 37;
}
}

View file

@ -35,35 +35,35 @@ import java.util.Collections;
import java.util.List;
public class FluidGeneratorRecipeDisplay implements RecipeDisplay {
private List<List<EntryStack>> inputs;
private Identifier category;
private int totalEnergy;
private final List<List<EntryStack>> inputs;
private final Identifier category;
private final int totalEnergy;
public FluidGeneratorRecipeDisplay(FluidGeneratorRecipe recipe, Identifier category) {
this.category = category;
this.inputs = Lists.newArrayList();
this.totalEnergy = recipe.getEnergyPerBucket();
inputs.add(Collections.singletonList(RebornEntryStack.create(recipe.getFluid(), 1000)));
}
@Override
public List<List<EntryStack>> getInputEntries() {
return inputs;
}
@Override
public List<EntryStack> getOutputEntries() {
return Lists.newArrayList();
}
@Override
public Identifier getRecipeCategory() {
return category;
}
public int getTotalEnergy() {
return totalEnergy;
}
}

View file

@ -44,52 +44,52 @@ import java.util.LinkedList;
import java.util.List;
public class FluidReplicatorRecipeCategory implements RecipeCategory<FluidReplicatorRecipeDisplay> {
private final RebornRecipeType<FluidReplicatorRecipe> rebornRecipeType;
public FluidReplicatorRecipeCategory(RebornRecipeType<FluidReplicatorRecipe> recipeType) {
this.rebornRecipeType = recipeType;
}
@Override
public Identifier getIdentifier() {
return rebornRecipeType.getName();
}
@Override
public String getCategoryName() {
return I18n.translate(rebornRecipeType.getName().toString());
}
@Override
public EntryStack getLogo() {
return EntryStack.create(ReiPlugin.iconMap.getOrDefault(rebornRecipeType, () -> Items.DIAMOND_SHOVEL));
}
@Override
public List<Widget> setupDisplay(FluidReplicatorRecipeDisplay machineRecipe, Rectangle bounds) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 13);
List<Widget> widgets = new LinkedList<>();
widgets.add(Widgets.createRecipeBase(bounds));
widgets.add(Widgets.createArrow(new Point(startPoint.x + 26, startPoint.y + 1)).animationDurationTicks(machineRecipe.getTime()));
int i = 0;
for (List<EntryStack> inputs : machineRecipe.getInputEntries()) {
widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1 + (i++ * 20))).entries(inputs).markInput());
}
Text energyPerTick = new TranslatableText("techreborn.jei.recipe.running.cost", "E", machineRecipe.getEnergy());
Label costLabel;
widgets.add(costLabel = Widgets.createLabel(new Point(startPoint.x + 1, startPoint.y + 1 + (i++ * 20)), energyPerTick));
costLabel.shadow(false);
costLabel.color(0xFF404040, 0xFFBBBBBB);
if (!machineRecipe.getOutputEntries().isEmpty())
widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 1)).entries(machineRecipe.getOutputEntries()).markInput());
return widgets;
}
}

View file

@ -39,14 +39,14 @@ import java.util.List;
* @author drcrazy
*/
public class FluidReplicatorRecipeDisplay implements RecipeDisplay {
private final FluidReplicatorRecipe recipe;
private List<List<EntryStack>> inputs;
private List<EntryStack> output;
private FluidInstance fluidInstance;
private final List<List<EntryStack>> inputs;
private final List<EntryStack> output;
private final FluidInstance fluidInstance;
private int energy = 0;
private int time = 0;
public FluidReplicatorRecipeDisplay(FluidReplicatorRecipe recipe) {
this.recipe = recipe;
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> CollectionUtils.map(ing.getPreviewStacks(), RebornEntryStack::create));
@ -55,34 +55,34 @@ public class FluidReplicatorRecipeDisplay implements RecipeDisplay {
this.energy = recipe.getPower();
this.time = recipe.getTime();
}
public FluidInstance getFluidInstance() {
return fluidInstance;
}
public int getEnergy() {
return energy;
}
public int getTime() {
return time;
}
@Override
public List<List<EntryStack>> getInputEntries() {
return inputs;
}
@Override
public List<EntryStack> getOutputEntries() {
return output;
}
@Override
public List<List<EntryStack>> getRequiredEntries() {
return inputs;
}
@Override
public Identifier getRecipeCategory() {
return recipe.getRebornRecipeType().getName();

View file

@ -34,26 +34,26 @@ import techreborn.api.recipe.recipes.RollingMachineRecipe;
import techreborn.compat.rei.ReiPlugin;
public class RollingMachineCategory extends DefaultCraftingCategory {
private final RebornRecipeType<RollingMachineRecipe> rebornRecipeType;
public RollingMachineCategory(RebornRecipeType<RollingMachineRecipe> rebornRecipeType) {
this.rebornRecipeType = rebornRecipeType;
}
@Override
public Identifier getIdentifier() {
return rebornRecipeType.getName();
}
@Override
public String getCategoryName() {
return I18n.translate(rebornRecipeType.getName().toString());
}
@Override
public EntryStack getLogo() {
return EntryStack.create(ReiPlugin.iconMap.getOrDefault(rebornRecipeType, () -> Items.DIAMOND_SHOVEL));
}
}