@@ -19,29 +19,33 @@
|
||||
package appeng.recipes.game;
|
||||
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IComparableDefinition;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.SpecialRecipe;
|
||||
import net.minecraft.item.crafting.SpecialRecipeSerializer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
public final class FacadeRecipe extends net.minecraftforge.registries.IForgeRegistryEntry.Impl<IRecipe> implements IRecipe
|
||||
public final class FacadeRecipe extends SpecialRecipe
|
||||
{
|
||||
public static SpecialRecipeSerializer<FacadeRecipe> SERIALIZER = null;
|
||||
|
||||
private final IComparableDefinition anchor;
|
||||
private final ItemFacade facade;
|
||||
|
||||
public FacadeRecipe( ItemFacade facade )
|
||||
public FacadeRecipe( ResourceLocation id, ItemFacade facade )
|
||||
{
|
||||
super( id );
|
||||
this.facade = facade;
|
||||
final IDefinitions definitions = Api.INSTANCE.definitions();
|
||||
|
||||
@@ -49,12 +53,12 @@ public final class FacadeRecipe extends net.minecraftforge.registries.IForgeRegi
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final CraftingInventory inv, final World w )
|
||||
public boolean matches( @Nonnull final CraftingInventory inv, @Nonnull final World w )
|
||||
{
|
||||
return !this.getOutput( inv, false ).isEmpty();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Nonnull
|
||||
private ItemStack getOutput( final IInventory inv, final boolean createFacade )
|
||||
{
|
||||
if( inv.getStackInSlot( 0 ).isEmpty() && inv.getStackInSlot( 2 ).isEmpty() && inv.getStackInSlot( 6 ).isEmpty() && inv.getStackInSlot( 8 ).isEmpty() )
|
||||
@@ -75,7 +79,7 @@ public final class FacadeRecipe extends net.minecraftforge.registries.IForgeRegi
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult( final CraftingInventory inv )
|
||||
public ItemStack getCraftingResult( @Nonnull final CraftingInventory inv )
|
||||
{
|
||||
return this.getOutput( inv, true );
|
||||
}
|
||||
@@ -86,15 +90,21 @@ public final class FacadeRecipe extends net.minecraftforge.registries.IForgeRegi
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() // no default output..
|
||||
public IRecipeSerializer<FacadeRecipe> getSerializer()
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
return getSerializer( facade );
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonNullList<ItemStack> getRemainingItems( final CraftingInventory inv )
|
||||
public static IRecipeSerializer<FacadeRecipe> getSerializer( ItemFacade facade )
|
||||
{
|
||||
return ForgeHooks.defaultRecipeGetRemainingItems( inv );
|
||||
if( SERIALIZER == null )
|
||||
{
|
||||
SERIALIZER = new SpecialRecipeSerializer<>( id -> new FacadeRecipe( id, facade ) );
|
||||
SERIALIZER.setRegistryName( new ResourceLocation( AppEng.MOD_ID, "facade_recipe" ) );
|
||||
}
|
||||
return SERIALIZER;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user