Corrected Toast icons for fusion computer and centrifuge

Centrifuge one is a bit hacky (we add dummy classes), but better than putting an if into RebornRecipe and faster+safer than correcting the differences between centrifuge and industrial_centrifuge in the code.
This commit is contained in:
Ayutac 2022-02-11 21:40:39 +01:00
parent 3101b9a5b6
commit d200f931f3
4 changed files with 46 additions and 6 deletions

View file

@ -34,15 +34,14 @@ import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeSerializer; import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World; import net.minecraft.world.World;
import reborncore.RebornCore;
import reborncore.api.recipe.IRecipeCrafterProvider; import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.common.crafting.ingredient.RebornIngredient; import reborncore.common.crafting.ingredient.RebornIngredient;
import reborncore.common.util.DefaultedListCollector; import reborncore.common.util.DefaultedListCollector;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class RebornRecipe implements Recipe<Inventory>, CustomOutputRecipe { public class RebornRecipe implements Recipe<Inventory>, CustomOutputRecipe {
private final RebornRecipeType<?> type; private final RebornRecipeType<?> type;
@ -62,6 +61,16 @@ public class RebornRecipe implements Recipe<Inventory>, CustomOutputRecipe {
this.time = time; this.time = time;
} }
@Override
public ItemStack createIcon() {
Optional<Item> catalyst = Registry.ITEM.getOrEmpty(type.name());
if (catalyst.isPresent())
return new ItemStack(catalyst.get());
else
RebornCore.LOGGER.warn("Missing toast icon for {}!", type.name());
return Recipe.super.createIcon();
}
@Override @Override
public Identifier getId() { public Identifier getId() {
return name; return name;
@ -166,7 +175,7 @@ public class RebornRecipe implements Recipe<Inventory>, CustomOutputRecipe {
// Done to try and stop the table from loading it // Done to try and stop the table from loading it
@Override @Override
public boolean isIgnoredInRecipeBook() { public boolean isIgnoredInRecipeBook() {
return true; return false;
} }
@Override @Override

View file

@ -0,0 +1,23 @@
package techreborn.api.recipe.recipes;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import reborncore.common.crafting.ingredient.RebornIngredient;
import techreborn.init.TRContent;
import java.util.List;
public class CentrifugeRecipe extends RebornRecipe {
public CentrifugeRecipe(RebornRecipeType<?> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time) {
super(type, name, ingredients, outputs, power, time);
}
@Override
public ItemStack createIcon() {
return new ItemStack(TRContent.Machine.INDUSTRIAL_CENTRIFUGE);
}
}

View file

@ -31,6 +31,7 @@ import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType; import reborncore.common.crafting.RebornRecipeType;
import reborncore.common.crafting.ingredient.RebornIngredient; import reborncore.common.crafting.ingredient.RebornIngredient;
import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntity; import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntity;
import techreborn.init.TRContent;
import java.util.List; import java.util.List;
@ -47,6 +48,11 @@ public class FusionReactorRecipe extends RebornRecipe {
this.minSize = minSize; this.minSize = minSize;
} }
@Override
public ItemStack createIcon() {
return new ItemStack(TRContent.Machine.FUSION_CONTROL_COMPUTER);
}
public int getStartEnergy() { public int getStartEnergy() {
return startE; return startE;
} }

View file

@ -30,6 +30,7 @@ import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType; import reborncore.common.crafting.RebornRecipeType;
import reborncore.common.crafting.RecipeManager; import reborncore.common.crafting.RecipeManager;
import reborncore.common.crafting.serde.RebornFluidRecipeSerde; import reborncore.common.crafting.serde.RebornFluidRecipeSerde;
import reborncore.common.crafting.serde.RebornRecipeSerde;
import techreborn.api.recipe.recipes.*; import techreborn.api.recipe.recipes.*;
import techreborn.api.recipe.recipes.serde.BlastFurnaceRecipeSerde; import techreborn.api.recipe.recipes.serde.BlastFurnaceRecipeSerde;
import techreborn.api.recipe.recipes.serde.FusionReactorRecipeSerde; import techreborn.api.recipe.recipes.serde.FusionReactorRecipeSerde;
@ -42,11 +43,12 @@ public class ModRecipes {
public static final RebornFluidRecipeSerde<FluidReplicatorRecipe> FLUID_REPLICATOR_RECIPE_SERDE = RebornFluidRecipeSerde.create(FluidReplicatorRecipe::new); public static final RebornFluidRecipeSerde<FluidReplicatorRecipe> FLUID_REPLICATOR_RECIPE_SERDE = RebornFluidRecipeSerde.create(FluidReplicatorRecipe::new);
public static final FusionReactorRecipeSerde FUSION_REACTOR_RECIPE_SERDE = new FusionReactorRecipeSerde(); public static final FusionReactorRecipeSerde FUSION_REACTOR_RECIPE_SERDE = new FusionReactorRecipeSerde();
public static final RollingMachineRecipeSerde ROLLING_MACHINE_RECIPE_SERDE = new RollingMachineRecipeSerde(); public static final RollingMachineRecipeSerde ROLLING_MACHINE_RECIPE_SERDE = new RollingMachineRecipeSerde();
public static final RebornRecipeSerde<CentrifugeRecipe> CENTRIFUGE_RECIPE_SERDE = RebornRecipeSerde.create(CentrifugeRecipe::new);
public static final RebornRecipeType<RebornRecipe> ALLOY_SMELTER = RecipeManager.newRecipeType(new Identifier("techreborn:alloy_smelter")); public static final RebornRecipeType<RebornRecipe> ALLOY_SMELTER = RecipeManager.newRecipeType(new Identifier("techreborn:alloy_smelter"));
public static final RebornRecipeType<RebornRecipe> ASSEMBLING_MACHINE = RecipeManager.newRecipeType(new Identifier("techreborn:assembling_machine")); public static final RebornRecipeType<RebornRecipe> ASSEMBLING_MACHINE = RecipeManager.newRecipeType(new Identifier("techreborn:assembling_machine"));
public static final RebornRecipeType<BlastFurnaceRecipe> BLAST_FURNACE = RecipeManager.newRecipeType(BLAST_FURNACE_RECIPE_SERDE, new Identifier("techreborn:blast_furnace")); public static final RebornRecipeType<BlastFurnaceRecipe> BLAST_FURNACE = RecipeManager.newRecipeType(BLAST_FURNACE_RECIPE_SERDE, new Identifier("techreborn:blast_furnace"));
public static final RebornRecipeType<RebornRecipe> CENTRIFUGE = RecipeManager.newRecipeType(new Identifier("techreborn:centrifuge")); public static final RebornRecipeType<CentrifugeRecipe> CENTRIFUGE = RecipeManager.newRecipeType(CENTRIFUGE_RECIPE_SERDE, new Identifier("techreborn:centrifuge"));
public static final RebornRecipeType<RebornRecipe> CHEMICAL_REACTOR = RecipeManager.newRecipeType(new Identifier("techreborn:chemical_reactor")); public static final RebornRecipeType<RebornRecipe> CHEMICAL_REACTOR = RecipeManager.newRecipeType(new Identifier("techreborn:chemical_reactor"));
public static final RebornRecipeType<RebornRecipe> COMPRESSOR = RecipeManager.newRecipeType(new Identifier("techreborn:compressor")); public static final RebornRecipeType<RebornRecipe> COMPRESSOR = RecipeManager.newRecipeType(new Identifier("techreborn:compressor"));
public static final RebornRecipeType<RebornRecipe> DISTILLATION_TOWER = RecipeManager.newRecipeType(new Identifier("techreborn:distillation_tower")); public static final RebornRecipeType<RebornRecipe> DISTILLATION_TOWER = RecipeManager.newRecipeType(new Identifier("techreborn:distillation_tower"));