1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-11-08 09:23:00 +00:00

Add ore dictionary support to all recipes

This commit is contained in:
SquidDev
2018-02-04 20:02:12 +00:00
parent 3b3dd8071b
commit 3ac76bc05b
21 changed files with 57 additions and 53 deletions

View File

@@ -10,19 +10,23 @@ import dan200.computercraft.shared.media.items.ItemDiskLegacy;
import dan200.computercraft.shared.util.Colour;
import dan200.computercraft.shared.util.ColourTracker;
import dan200.computercraft.shared.util.ColourUtils;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.oredict.OreIngredient;
import net.minecraftforge.registries.IForgeRegistryEntry;
import javax.annotation.Nonnull;
public class DiskRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe
{
private final Ingredient paper = new OreIngredient( "paper" );
private final Ingredient redstone = new OreIngredient( "dustRedstone" );
@Override
public boolean matches( @Nonnull InventoryCrafting inv, @Nonnull World world )
{
@@ -35,12 +39,12 @@ public class DiskRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRe
if( !stack.isEmpty() )
{
if( stack.getItem() == Items.PAPER )
if( paper.apply( stack ) )
{
if( paperFound ) return false;
paperFound = true;
}
else if( stack.getItem() == Items.REDSTONE )
else if( redstone.apply( stack ) )
{
if( redstoneFound ) return false;
redstoneFound = true;
@@ -66,8 +70,8 @@ public class DiskRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRe
ItemStack stack = inv.getStackInSlot( i );
if( stack.isEmpty() ) continue;
if( stack.getItem() != Items.PAPER && stack.getItem() != Items.REDSTONE )
if( !paper.apply( stack ) && !redstone.apply( stack ) )
{
int index = ColourUtils.getStackColour( stack );
if( index < 0 ) continue;

View File

@@ -7,23 +7,24 @@
package dan200.computercraft.shared.media.recipes;
import dan200.computercraft.shared.media.items.ItemPrintout;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.oredict.OreIngredient;
import net.minecraftforge.registries.IForgeRegistryEntry;
import javax.annotation.Nonnull;
public class PrintoutRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe
{
public PrintoutRecipe( )
{
}
private final Ingredient paper = new OreIngredient( "paper" );
private final Ingredient leather = new OreIngredient( "leather" );
private final Ingredient string = new OreIngredient( "string" );
@Override
public boolean canFit( int x, int y )
@@ -68,8 +69,7 @@ public class PrintoutRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements
ItemStack stack = inventory.getStackInRowAndColumn(x, y);
if( !stack.isEmpty() )
{
Item item = stack.getItem();
if( item instanceof ItemPrintout && ItemPrintout.getType( stack ) != ItemPrintout.Type.Book )
if( stack.getItem() instanceof ItemPrintout && ItemPrintout.getType( stack ) != ItemPrintout.Type.Book )
{
if( printouts == null )
{
@@ -80,7 +80,7 @@ public class PrintoutRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements
numPrintouts++;
printoutFound = true;
}
else if( item == Items.PAPER )
else if( paper.apply( stack ) )
{
if( printouts == null )
{
@@ -90,11 +90,11 @@ public class PrintoutRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements
numPages++;
numPrintouts++;
}
else if( item == Items.STRING && !stringFound )
else if( string.apply( stack ) && !stringFound )
{
stringFound = true;
}
else if( item == Items.LEATHER && !leatherFound )
else if( leather.apply( stack ) && !leatherFound )
{
leatherFound = true;
}