1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-19 13:42:57 +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.Colour;
import dan200.computercraft.shared.util.ColourTracker; import dan200.computercraft.shared.util.ColourTracker;
import dan200.computercraft.shared.util.ColourUtils; import dan200.computercraft.shared.util.ColourUtils;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.oredict.OreIngredient;
import net.minecraftforge.registries.IForgeRegistryEntry; import net.minecraftforge.registries.IForgeRegistryEntry;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public class DiskRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe public class DiskRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe
{ {
private final Ingredient paper = new OreIngredient( "paper" );
private final Ingredient redstone = new OreIngredient( "dustRedstone" );
@Override @Override
public boolean matches( @Nonnull InventoryCrafting inv, @Nonnull World world ) 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.isEmpty() )
{ {
if( stack.getItem() == Items.PAPER ) if( paper.apply( stack ) )
{ {
if( paperFound ) return false; if( paperFound ) return false;
paperFound = true; paperFound = true;
} }
else if( stack.getItem() == Items.REDSTONE ) else if( redstone.apply( stack ) )
{ {
if( redstoneFound ) return false; if( redstoneFound ) return false;
redstoneFound = true; redstoneFound = true;
@ -67,7 +71,7 @@ public class DiskRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRe
if( stack.isEmpty() ) continue; 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 ); int index = ColourUtils.getStackColour( stack );
if( index < 0 ) continue; if( index < 0 ) continue;

View File

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

View File

@ -6,9 +6,9 @@
"#G#" "#G#"
], ],
"key": { "key": {
"#": { "item": "minecraft:gold_ingot" }, "#": { "type": "forge:ore_dict", "ore": "ingotGold" },
"R": { "item": "minecraft:redstone" }, "R": { "type": "forge:ore_dict", "ore": "dustRedstone" },
"G": { "item": "minecraft:glass_pane" } "G": { "type": "forge:ore_dict", "ore": "paneGlass" }
}, },
"result": { "item": "computercraft:computer", "data": 16384 } "result": { "item": "computercraft:computer", "data": 16384 }
} }

View File

@ -6,8 +6,8 @@
"###" "###"
], ],
"key": { "key": {
"#": { "item": "minecraft:gold_ingot" }, "#": { "type": "forge:ore_dict", "ore": "ingotGold" },
"G": { "item": "minecraft:glass_pane" } "G": { "type": "forge:ore_dict", "ore": "paneGlass" }
}, },
"result": { "item": "computercraft:peripheral", "data": 4, "count": 4 } "result": { "item": "computercraft:peripheral", "data": 4, "count": 4 }
} }

View File

@ -6,8 +6,8 @@
"#G#" "#G#"
], ],
"key": { "key": {
"#": { "item": "minecraft:gold_ingot" }, "#": { "type": "forge:ore_dict", "ore": "ingotGold" },
"G": { "item": "minecraft:glass_pane" }, "G": { "type": "forge:ore_dict", "ore": "paneGlass" },
"A": { "item": "minecraft:golden_apple", "data": 0 } "A": { "item": "minecraft:golden_apple", "data": 0 }
}, },
"result": { "item": "computercraft:pocket_computer", "data": 1 } "result": { "item": "computercraft:pocket_computer", "data": 1 }

View File

@ -6,9 +6,9 @@
"#I#" "#I#"
], ],
"key": { "key": {
"#": { "item": "minecraft:gold_ingot" }, "#": { "type": "forge:ore_dict", "ore": "ingotGold" },
"C": { "item": "computercraft:computer", "data": 16384 }, "C": { "item": "computercraft:computer", "data": 16384 },
"I": { "item": "minecraft:chest" } "I": { "type": "forge:ore_dict", "ore": "chestWood" }
}, },
"family": "Advanced" "family": "Advanced"
} }

View File

@ -6,8 +6,8 @@
" # " " # "
], ],
"key": { "key": {
"#": { "item": "minecraft:stone", "data": 0 }, "#": { "type": "forge:ore_dict", "ore": "stone" },
"R": { "item": "minecraft:redstone" } "R": { "type": "forge:ore_dict", "ore": "dustRedstone" }
}, },
"result": { "item": "computercraft:cable", "data": 0, "count": 6 } "result": { "item": "computercraft:cable", "data": 0, "count": 6 }
} }

View File

@ -6,9 +6,9 @@
"#G#" "#G#"
], ],
"key": { "key": {
"#": { "item": "minecraft:stone", "data": 0 }, "#": { "type": "forge:ore_dict", "ore": "stone" },
"C": { "item": "minecraft:command_block" }, "C": { "item": "minecraft:command_block" },
"G": { "item": "minecraft:glass_pane" } "G": { "type": "forge:ore_dict", "ore": "paneGlass" }
}, },
"result": { "item": "computercraft:command_computer", "data": 0 } "result": { "item": "computercraft:command_computer", "data": 0 }
} }

View File

@ -6,8 +6,8 @@
"#R#" "#R#"
], ],
"key": { "key": {
"#": { "item": "minecraft:stone", "data": 0 }, "#": { "type": "forge:ore_dict", "ore": "stone" },
"R": { "item": "minecraft:redstone" } "R": { "type": "forge:ore_dict", "ore": "dustRedstone" }
}, },
"result": { "item": "computercraft:peripheral", "data": 0 } "result": { "item": "computercraft:peripheral", "data": 0 }
} }

View File

@ -1,8 +1,8 @@
{ {
"type": "computercraft:impostor_shapeless", "type": "computercraft:impostor_shapeless",
"ingredients": [ "ingredients": [
{ "item": "minecraft:redstone" }, { "type": "forge:ore_dict", "ore": "dustRedstone" },
{ "item": "minecraft:paper" } { "type": "forge:ore_dict", "ore": "paper" }
], ],
"result": { "item": "computercraft:disk", "data": 0 } "result": { "item": "computercraft:disk", "data": 0 }
} }

View File

@ -6,7 +6,7 @@
"###" "###"
], ],
"key": { "key": {
"#": { "item": "minecraft:gold_ingot" }, "#": { "type": "forge:ore_dict", "ore": "ingotGold" },
"E": { "item": "minecraft:ender_eye" } "E": { "item": "minecraft:ender_eye" }
}, },
"result": { "item": "computercraft:advanced_modem", "data": 0 } "result": { "item": "computercraft:advanced_modem", "data": 0 }

View File

@ -6,9 +6,9 @@
"#G#" "#G#"
], ],
"key": { "key": {
"#": { "item": "minecraft:stone", "data": 0 }, "#": { "type": "forge:ore_dict", "ore": "stone" },
"R": { "item": "minecraft:redstone" }, "R": { "type": "forge:ore_dict", "ore": "dustRedstone" },
"G": { "item": "minecraft:glass_pane" } "G": { "type": "forge:ore_dict", "ore": "paneGlass" }
}, },
"result": { "item": "computercraft:computer", "data": 0 } "result": { "item": "computercraft:computer", "data": 0 }
} }

View File

@ -6,8 +6,8 @@
"###" "###"
], ],
"key": { "key": {
"#": { "item": "minecraft:stone", "data": 0 }, "#": { "type": "forge:ore_dict", "ore": "stone" },
"G": { "item": "minecraft:glass_pane" } "G": { "type": "forge:ore_dict", "ore": "paneGlass" }
}, },
"result": { "item": "computercraft:peripheral", "data": 2 } "result": { "item": "computercraft:peripheral", "data": 2 }
} }

View File

@ -6,8 +6,8 @@
"#G#" "#G#"
], ],
"key": { "key": {
"#": { "item": "minecraft:stone", "data": 0 }, "#": { "type": "forge:ore_dict", "ore": "stone" },
"G": { "item": "minecraft:glass_pane" }, "G": { "type": "forge:ore_dict", "ore": "paneGlass" },
"A": { "item": "minecraft:golden_apple", "data": 0 } "A": { "item": "minecraft:golden_apple", "data": 0 }
}, },
"result": { "item": "computercraft:pocket_computer", "data": 0 } "result": { "item": "computercraft:pocket_computer", "data": 0 }

View File

@ -6,9 +6,9 @@
"#I#" "#I#"
], ],
"key": { "key": {
"#": { "item": "minecraft:iron_ingot" }, "#": { "type": "forge:ore_dict", "ore": "ingotIron" },
"C": { "item": "computercraft:computer", "data": 0 }, "C": { "item": "computercraft:computer", "data": 0 },
"I": { "item": "minecraft:chest" } "I": { "type": "forge:ore_dict", "ore": "chestWood" }
}, },
"family": "Normal" "family": "Normal"
} }

View File

@ -1,9 +1,9 @@
{ {
"type": "computercraft:impostor_shapeless", "type": "computercraft:impostor_shapeless",
"ingredients": [ "ingredients": [
{ "item": "minecraft:leather" }, { "type": "forge:ore_dict", "ore": "leather" },
{ "item": "computercraft:printout", "data": 0 }, { "item": "computercraft:printout", "data": 0 },
{ "item": "minecraft:string" } { "type": "forge:ore_dict", "ore": "string" }
], ],
"result": { "item": "computercraft:printout", "data": 2 } "result": { "item": "computercraft:printout", "data": 2 }
} }

View File

@ -3,7 +3,7 @@
"ingredients": [ "ingredients": [
{ "item": "computercraft:printout", "data": 0 }, { "item": "computercraft:printout", "data": 0 },
{ "item": "computercraft:printout", "data": 0 }, { "item": "computercraft:printout", "data": 0 },
{ "item": "minecraft:string" } { "type": "forge:ore_dict", "ore": "string" }
], ],
"result": { "item": "computercraft:printout", "data": 1 } "result": { "item": "computercraft:printout", "data": 1 }
} }

View File

@ -6,9 +6,9 @@
"#D#" "#D#"
], ],
"key": { "key": {
"#": { "item": "minecraft:stone", "data": 0 }, "#": { "type": "forge:ore_dict", "ore": "stone" },
"R": { "item": "minecraft:redstone" }, "R": { "type": "forge:ore_dict", "ore": "paneGlass" },
"D": { "item": "minecraft:dye", "data": 0 } "D": { "type": "forge:ore_dict", "ore": "dye" }
}, },
"result": { "item": "computercraft:peripheral", "data": 3 } "result": { "item": "computercraft:peripheral", "data": 3 }
} }

View File

@ -6,8 +6,8 @@
"#R#" "#R#"
], ],
"key": { "key": {
"#": { "item": "minecraft:stone", "data": 0 }, "#": { "type": "forge:ore_dict", "ore": "stone" },
"R": { "item": "minecraft:redstone" }, "R": { "type": "forge:ore_dict", "ore": "dustRedstone" },
"N": { "item": "minecraft:noteblock" } "N": { "item": "minecraft:noteblock" }
}, },
"result": { "item": "computercraft:peripheral", "data": 5 } "result": { "item": "computercraft:peripheral", "data": 5 }

View File

@ -6,8 +6,8 @@
"###" "###"
], ],
"key": { "key": {
"#": { "item": "minecraft:stone", "data": 0 }, "#": { "type": "forge:ore_dict", "ore": "stone" },
"R": { "item": "minecraft:redstone" } "R": { "type": "forge:ore_dict", "ore": "dustRedstone" }
}, },
"result": { "item": "computercraft:cable", "data": 1 } "result": { "item": "computercraft:cable", "data": 1 }
} }

View File

@ -6,8 +6,8 @@
"###" "###"
], ],
"key": { "key": {
"#": { "item": "minecraft:stone", "data": 0 }, "#": { "type": "forge:ore_dict", "ore": "stone" },
"E": { "item": "minecraft:ender_pearl" } "E": { "type": "forge:ore_dict", "ore": "enderpearl" }
}, },
"result": { "item": "computercraft:peripheral", "data": 1 } "result": { "item": "computercraft:peripheral", "data": 1 }
} }