Utils ported
This commit is contained in:
@@ -25,9 +25,9 @@ import java.util.Optional;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.item.crafting.SpecialRecipe;
|
||||
import net.minecraft.item.crafting.SpecialRecipeSerializer;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -46,7 +46,7 @@ import appeng.api.storage.data.IItemList;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public final class DisassembleRecipe extends SpecialRecipe {
|
||||
public static final IRecipeSerializer<DisassembleRecipe> SERIALIZER = new SpecialRecipeSerializer<>(
|
||||
public static final RecipeSerializer<DisassembleRecipe> SERIALIZER = new SpecialRecipeSerializer<>(
|
||||
DisassembleRecipe::new);
|
||||
|
||||
static {
|
||||
@@ -87,11 +87,11 @@ public final class DisassembleRecipe extends SpecialRecipe {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private ItemStack getOutput(final IInventory inventory) {
|
||||
private ItemStack getOutput(final Inventory inventory) {
|
||||
int itemCount = 0;
|
||||
ItemStack output = MISMATCHED_STACK;
|
||||
|
||||
for (int slotIndex = 0; slotIndex < inventory.getSizeInventory(); slotIndex++) {
|
||||
for (int slotIndex = 0; slotIndex < inventory.size(); slotIndex++) {
|
||||
final ItemStack stackInSlot = inventory.getStackInSlot(slotIndex);
|
||||
if (!stackInSlot.isEmpty()) {
|
||||
// needs a single input in the recipe
|
||||
@@ -150,7 +150,7 @@ public final class DisassembleRecipe extends SpecialRecipe {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getCraftingResult(@Nonnull final CraftingInventory inv) {
|
||||
public ItemStack craft(@Nonnull final CraftingInventory inv) {
|
||||
return this.getOutput(inv);
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ public final class DisassembleRecipe extends SpecialRecipe {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeSerializer<DisassembleRecipe> getSerializer() {
|
||||
public RecipeSerializer<DisassembleRecipe> getSerializer() {
|
||||
return SERIALIZER;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ package appeng.recipes.game;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.item.crafting.SpecialRecipe;
|
||||
import net.minecraft.item.crafting.SpecialRecipeSerializer;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -55,7 +55,7 @@ public final class FacadeRecipe extends SpecialRecipe {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private ItemStack getOutput(final IInventory inv, final boolean createFacade) {
|
||||
private ItemStack getOutput(final Inventory inv, final boolean createFacade) {
|
||||
if (inv.getStackInSlot(0).isEmpty() && inv.getStackInSlot(2).isEmpty() && inv.getStackInSlot(6).isEmpty()
|
||||
&& inv.getStackInSlot(8).isEmpty()) {
|
||||
if (this.anchor.isSameAs(inv.getStackInSlot(1)) && this.anchor.isSameAs(inv.getStackInSlot(3))
|
||||
@@ -72,7 +72,7 @@ public final class FacadeRecipe extends SpecialRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(@Nonnull final CraftingInventory inv) {
|
||||
public ItemStack craft(@Nonnull final CraftingInventory inv) {
|
||||
return this.getOutput(inv, true);
|
||||
}
|
||||
|
||||
@@ -83,11 +83,11 @@ public final class FacadeRecipe extends SpecialRecipe {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeSerializer<FacadeRecipe> getSerializer() {
|
||||
public RecipeSerializer<FacadeRecipe> getSerializer() {
|
||||
return getSerializer(facade);
|
||||
}
|
||||
|
||||
public static IRecipeSerializer<FacadeRecipe> getSerializer(FacadeItem facade) {
|
||||
public static RecipeSerializer<FacadeRecipe> getSerializer(FacadeItem facade) {
|
||||
if (SERIALIZER == null) {
|
||||
SERIALIZER = new SpecialRecipeSerializer<>(id -> new FacadeRecipe(id, facade));
|
||||
SERIALIZER.setRegistryName(new Identifier(AppEng.MOD_ID, "facade"));
|
||||
|
||||
@@ -4,19 +4,19 @@ import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GrinderRecipe implements IRecipe<IInventory> {
|
||||
public class GrinderRecipe implements Recipe<Inventory> {
|
||||
|
||||
public static IRecipeType<GrinderRecipe> TYPE;
|
||||
public static RecipeType<GrinderRecipe> TYPE;
|
||||
|
||||
private final Identifier id;
|
||||
private final String group;
|
||||
@@ -43,12 +43,12 @@ public class GrinderRecipe implements IRecipe<IInventory> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(IInventory inv, World worldIn) {
|
||||
public boolean matches(Inventory inv, World worldIn) {
|
||||
return this.ingredient.test(inv.getStackInSlot(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(IInventory inv) {
|
||||
public ItemStack craft(Inventory inv) {
|
||||
// FIXME: What about secondary output
|
||||
return this.result.copy();
|
||||
}
|
||||
@@ -69,12 +69,12 @@ public class GrinderRecipe implements IRecipe<IInventory> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeSerializer<?> getSerializer() {
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return GrinderRecipeSerializer.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeType<?> getType() {
|
||||
public RecipeType<?> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.item.crafting.ShapedRecipe;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -22,8 +22,8 @@ import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class GrinderRecipeSerializer extends ForgeRegistryEntry<IRecipeSerializer<?>>
|
||||
implements IRecipeSerializer<GrinderRecipe> {
|
||||
public class GrinderRecipeSerializer extends ForgeRegistryEntry<RecipeSerializer<?>>
|
||||
implements RecipeSerializer<GrinderRecipe> {
|
||||
|
||||
public static final GrinderRecipeSerializer INSTANCE = new GrinderRecipeSerializer();
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ package appeng.recipes.handlers;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public final class GrinderRecipes {
|
||||
@@ -18,7 +18,7 @@ public final class GrinderRecipes {
|
||||
*/
|
||||
@Nullable
|
||||
public static GrinderRecipe findForInput(World world, ItemStack input) {
|
||||
for (IRecipe<IInventory> recipe : world.getRecipeManager().getRecipes(GrinderRecipe.TYPE).values()) {
|
||||
for (Recipe<Inventory> recipe : world.getRecipeManager().getRecipes(GrinderRecipe.TYPE).values()) {
|
||||
GrinderRecipe grinderRecipe = (GrinderRecipe) recipe;
|
||||
if (grinderRecipe.getIngredient().test(input) && input.getCount() >= grinderRecipe.getIngredientCount()) {
|
||||
return grinderRecipe;
|
||||
@@ -32,7 +32,7 @@ public final class GrinderRecipes {
|
||||
* disregarding its current size.
|
||||
*/
|
||||
public static boolean isValidIngredient(World world, ItemStack stack) {
|
||||
for (IRecipe<IInventory> recipe : world.getRecipeManager().getRecipes(GrinderRecipe.TYPE).values()) {
|
||||
for (Recipe<Inventory> recipe : world.getRecipeManager().getRecipes(GrinderRecipe.TYPE).values()) {
|
||||
GrinderRecipe grinderRecipe = (GrinderRecipe) recipe;
|
||||
if (grinderRecipe.getIngredient().test(stack)) {
|
||||
return true;
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.recipe.*;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
|
||||
public class InscriberRecipe implements IRecipe<IInventory> {
|
||||
public class InscriberRecipe implements Recipe<Inventory> {
|
||||
|
||||
public static IRecipeType<InscriberRecipe> TYPE;
|
||||
public static RecipeType<InscriberRecipe> TYPE;
|
||||
|
||||
private final Identifier id;
|
||||
private final String group;
|
||||
@@ -37,12 +36,12 @@ public class InscriberRecipe implements IRecipe<IInventory> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(IInventory inv, World worldIn) {
|
||||
public boolean matches(Inventory inv, World worldIn) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(IInventory inv) {
|
||||
public ItemStack craft(Inventory inv) {
|
||||
return this.output.copy();
|
||||
}
|
||||
|
||||
@@ -62,12 +61,12 @@ public class InscriberRecipe implements IRecipe<IInventory> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeSerializer<?> getSerializer() {
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return InscriberRecipeSerializer.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeType<?> getType() {
|
||||
public RecipeType<?> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ import javax.annotation.Nullable;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.item.crafting.ShapedRecipe;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -16,8 +16,8 @@ import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class InscriberRecipeSerializer extends ForgeRegistryEntry<IRecipeSerializer<?>>
|
||||
implements IRecipeSerializer<InscriberRecipe> {
|
||||
public class InscriberRecipeSerializer extends ForgeRegistryEntry<RecipeSerializer<?>>
|
||||
implements RecipeSerializer<InscriberRecipe> {
|
||||
|
||||
public static final InscriberRecipeSerializer INSTANCE = new InscriberRecipeSerializer();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user