Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@
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 )
{
Expand All @@ -35,12 +39,12 @@ public boolean matches( @Nonnull InventoryCrafting inv, @Nonnull World world )

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;
Expand All @@ -66,8 +70,8 @@ public ItemStack getCraftingResult( @Nonnull InventoryCrafting inv )
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -68,8 +69,7 @@ public ItemStack getCraftingResult( @Nonnull InventoryCrafting inventory )
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 )
{
Expand All @@ -80,7 +80,7 @@ public ItemStack getCraftingResult( @Nonnull InventoryCrafting inventory )
numPrintouts++;
printoutFound = true;
}
else if( item == Items.PAPER )
else if( paper.apply( stack ) )
{
if( printouts == null )
{
Expand All @@ -90,11 +90,11 @@ else if( item == Items.PAPER )
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"#G#"
],
"key": {
"#": { "item": "minecraft:gold_ingot" },
"R": { "item": "minecraft:redstone" },
"G": { "item": "minecraft:glass_pane" }
"#": { "type": "forge:ore_dict", "ore": "ingotGold" },
"R": { "type": "forge:ore_dict", "ore": "dustRedstone" },
"G": { "type": "forge:ore_dict", "ore": "paneGlass" }
},
"result": { "item": "computercraft:computer", "data": 16384 }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"###"
],
"key": {
"#": { "item": "minecraft:gold_ingot" },
"G": { "item": "minecraft:glass_pane" }
"#": { "type": "forge:ore_dict", "ore": "ingotGold" },
"G": { "type": "forge:ore_dict", "ore": "paneGlass" }
},
"result": { "item": "computercraft:peripheral", "data": 4, "count": 4 }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"#G#"
],
"key": {
"#": { "item": "minecraft:gold_ingot" },
"G": { "item": "minecraft:glass_pane" },
"#": { "type": "forge:ore_dict", "ore": "ingotGold" },
"G": { "type": "forge:ore_dict", "ore": "paneGlass" },
"A": { "item": "minecraft:golden_apple", "data": 0 }
},
"result": { "item": "computercraft:pocket_computer", "data": 1 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"#I#"
],
"key": {
"#": { "item": "minecraft:gold_ingot" },
"#": { "type": "forge:ore_dict", "ore": "ingotGold" },
"C": { "item": "computercraft:computer", "data": 16384 },
"I": { "item": "minecraft:chest" }
"I": { "type": "forge:ore_dict", "ore": "chestWood" }
},
"family": "Advanced"
}
4 changes: 2 additions & 2 deletions src/main/resources/assets/computercraft/recipes/cable.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
" # "
],
"key": {
"#": { "item": "minecraft:stone", "data": 0 },
"R": { "item": "minecraft:redstone" }
"#": { "type": "forge:ore_dict", "ore": "stone" },
"R": { "type": "forge:ore_dict", "ore": "dustRedstone" }
},
"result": { "item": "computercraft:cable", "data": 0, "count": 6 }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"#G#"
],
"key": {
"#": { "item": "minecraft:stone", "data": 0 },
"#": { "type": "forge:ore_dict", "ore": "stone" },
"C": { "item": "minecraft:command_block" },
"G": { "item": "minecraft:glass_pane" }
"G": { "type": "forge:ore_dict", "ore": "paneGlass" }
},
"result": { "item": "computercraft:command_computer", "data": 0 }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"#R#"
],
"key": {
"#": { "item": "minecraft:stone", "data": 0 },
"R": { "item": "minecraft:redstone" }
"#": { "type": "forge:ore_dict", "ore": "stone" },
"R": { "type": "forge:ore_dict", "ore": "dustRedstone" }
},
"result": { "item": "computercraft:peripheral", "data": 0 }
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"type": "computercraft:impostor_shapeless",
"ingredients": [
{ "item": "minecraft:redstone" },
{ "item": "minecraft:paper" }
{ "type": "forge:ore_dict", "ore": "dustRedstone" },
{ "type": "forge:ore_dict", "ore": "paper" }
],
"result": { "item": "computercraft:disk", "data": 0 }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"###"
],
"key": {
"#": { "item": "minecraft:gold_ingot" },
"#": { "type": "forge:ore_dict", "ore": "ingotGold" },
"E": { "item": "minecraft:ender_eye" }
},
"result": { "item": "computercraft:advanced_modem", "data": 0 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"#G#"
],
"key": {
"#": { "item": "minecraft:stone", "data": 0 },
"R": { "item": "minecraft:redstone" },
"G": { "item": "minecraft:glass_pane" }
"#": { "type": "forge:ore_dict", "ore": "stone" },
"R": { "type": "forge:ore_dict", "ore": "dustRedstone" },
"G": { "type": "forge:ore_dict", "ore": "paneGlass" }
},
"result": { "item": "computercraft:computer", "data": 0 }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"###"
],
"key": {
"#": { "item": "minecraft:stone", "data": 0 },
"G": { "item": "minecraft:glass_pane" }
"#": { "type": "forge:ore_dict", "ore": "stone" },
"G": { "type": "forge:ore_dict", "ore": "paneGlass" }
},
"result": { "item": "computercraft:peripheral", "data": 2 }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"#G#"
],
"key": {
"#": { "item": "minecraft:stone", "data": 0 },
"G": { "item": "minecraft:glass_pane" },
"#": { "type": "forge:ore_dict", "ore": "stone" },
"G": { "type": "forge:ore_dict", "ore": "paneGlass" },
"A": { "item": "minecraft:golden_apple", "data": 0 }
},
"result": { "item": "computercraft:pocket_computer", "data": 0 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"#I#"
],
"key": {
"#": { "item": "minecraft:iron_ingot" },
"#": { "type": "forge:ore_dict", "ore": "ingotIron" },
"C": { "item": "computercraft:computer", "data": 0 },
"I": { "item": "minecraft:chest" }
"I": { "type": "forge:ore_dict", "ore": "chestWood" }
},
"family": "Normal"
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"type": "computercraft:impostor_shapeless",
"ingredients": [
{ "item": "minecraft:leather" },
{ "type": "forge:ore_dict", "ore": "leather" },
{ "item": "computercraft:printout", "data": 0 },
{ "item": "minecraft:string" }
{ "type": "forge:ore_dict", "ore": "string" }
],
"result": { "item": "computercraft:printout", "data": 2 }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"ingredients": [
{ "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 }
}
6 changes: 3 additions & 3 deletions src/main/resources/assets/computercraft/recipes/printer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"#D#"
],
"key": {
"#": { "item": "minecraft:stone", "data": 0 },
"R": { "item": "minecraft:redstone" },
"D": { "item": "minecraft:dye", "data": 0 }
"#": { "type": "forge:ore_dict", "ore": "stone" },
"R": { "type": "forge:ore_dict", "ore": "paneGlass" },
"D": { "type": "forge:ore_dict", "ore": "dye" }
},
"result": { "item": "computercraft:peripheral", "data": 3 }
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{ "item": "minecraft:skull", "data": 1 },
{ "item": "minecraft:skull", "data": 32767 },
Copy link
Copy Markdown

@KnightMiner KnightMiner Jun 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wildcard metadata is deprecated by Mojang, it will no longer work in 1.13 and does not show properly in the recipe book in 1.12. Mojang replaced all uses of it with a list of ingredients. Since its reused, make that list of skulls a constant

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh, thanks. I've used it without problem with JEI, but forgot to test the recipe book.

Out of interest, what's the recommended way of dealing with items like wool, where there's no corresponding ore-dict entry? Obviously in 1.13 we can use item tags, but it also seems a little sub-optimal to list all 16 variants.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, all recipes that use all 16 variants of wool in 1.12 listed all 16 variants. You could also just add your own oredict entry to the vanilla items to supplement until tags are added in 1.13, as I'm sure other mods add their own wools too for the oredict

{ "item": "computercraft:peripheral", "data": 2 }
],
"result": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{ "item": "minecraft:skull", "data": 1 },
{ "item": "minecraft:skull", "data": 32767 },
{ "item": "computercraft:computer", "data": 0 }
],
"result": {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/computercraft/recipes/speaker.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"#R#"
],
"key": {
"#": { "item": "minecraft:stone", "data": 0 },
"R": { "item": "minecraft:redstone" },
"#": { "type": "forge:ore_dict", "ore": "stone" },
"R": { "type": "forge:ore_dict", "ore": "dustRedstone" },
"N": { "item": "minecraft:noteblock" }
},
"result": { "item": "computercraft:peripheral", "data": 5 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"###"
],
"key": {
"#": { "item": "minecraft:stone", "data": 0 },
"R": { "item": "minecraft:redstone" }
"#": { "type": "forge:ore_dict", "ore": "stone" },
"R": { "type": "forge:ore_dict", "ore": "dustRedstone" }
},
"result": { "item": "computercraft:cable", "data": 1 }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"###"
],
"key": {
"#": { "item": "minecraft:stone", "data": 0 },
"E": { "item": "minecraft:ender_pearl" }
"#": { "type": "forge:ore_dict", "ore": "stone" },
"E": { "type": "forge:ore_dict", "ore": "enderpearl" }
},
"result": { "item": "computercraft:peripheral", "data": 1 }
}