this is a tutorial on how to make a new block that just just like a crafting table, except it has custom recipies that dont work in a normal crafting table
1. create a new block in your mod_file
2. you need to create a new crafting manager, i call mine CraftingManager2
CraftingManager2/only recipies that use all vanilla items can be put in this file, recipies useing mod items will be in another file we create later
public int compare(Object par1Obj, Object par2Obj)
{
return compareRecipes((IRecipe)par1Obj, (IRecipe)par2Obj);
}
}
now we need to make a ContainerCrafting2 file that helps with our gui
note about replacing NameHereBlock with your block
package net.minecraft.src;
import java.util.List;
public class ContainerWorkbench2 extends Container
{
/** The crafting matrix inventory (3x3). */
public InventoryCrafting craftMatrix;
public IInventory craftResult;
private World worldObj;
private int posX;
private int posY;
private int posZ;
public ContainerWorkbench2(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5)
{
craftMatrix = new InventoryCrafting(this, 3, 3);
craftResult = new InventoryCraftResult();
worldObj = par2World;
posX = par3;
posY = par4;
posZ = par5;
addSlot(new SlotCrafting(par1InventoryPlayer.player, craftMatrix, craftResult, 0, 124, 35));
for (int i = 0; i < 3; i++)
{
for (int l = 0; l < 3; l++)
{
addSlot(new Slot(craftMatrix, l + i * 3, 30 + l * 18, 17 + i * 18));
}
}
for (int k = 0; k < 9; k++)
{
addSlot(new Slot(par1InventoryPlayer, k, 8 + k * 18, 142));
}
onCraftMatrixChanged(craftMatrix);
}
/**
* Callback for when the crafting matrix is changed.
*/
public void onCraftMatrixChanged(IInventory par1IInventory)
{
craftResult.setInventorySlotContents(0, CraftingManager2.getInstance().findMatchingRecipe(craftMatrix));
}
/**
* Callback for when the crafting gui is closed.
*/
public void onCraftGuiClosed(EntityPlayer par1EntityPlayer)
{
super.onCraftGuiClosed(par1EntityPlayer);
if (worldObj.isRemote)
{
return;
}
for (int i = 0; i < 9; i++)
{
ItemStack itemstack = craftMatrix.getStackInSlotOnClosing(i);
if (itemstack != null)
{
par1EntityPlayer.dropPlayerItem(itemstack);
}
}
}
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
{
//change this block to whatever the block you made in your mod_file
if (worldObj.getBlockId(posX, posY, posZ) != mod_NameHere.NameHere.blockID)
{
return false;
}
/**
* Called to transfer a stack from one inventory to the other eg. when shift clicking.
*/
public ItemStack transferStackInSlot(int par1)
{
ItemStack itemstack = null;
Slot slot = (Slot)inventorySlots.get(par1);
now we need to make our gui for when we open our crafting table/this is called GuiCrafting2
the image needs to be in minecrafts gui file found in the minecraft .jar
public class GuiCrafting2 extends GuiContainer
{
public GuiCrafting2(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5)
{
super(new ContainerWorkbench2(par1InventoryPlayer, par2World, par3, par4, par5));
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
super.onGuiClosed();
}
/**
* Draw the foreground layer for the GuiContainer (everythin in front of the items)
*/
protected void drawGuiContainerForegroundLayer()
{
fontRenderer.drawString(StatCollector.translateToLocal("container.crafting"), 28, 6, 0x404040);
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
}
/**
* Draw the background layer for the GuiContainer (everything behind the items)
*/
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int i = mc.renderEngine.getTexture("/gui/DnaMixing.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(i);
int j = (width - xSize) / 2;
int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
}
}
next we need our custom block file that will tell minecraft to open our gui
package net.minecraft.src;
public class BlockCraftingTable2 extends Block
{
protected BlockCraftingTable2(int par1)
{
super(par1, Material.wood);
blockIndexInTexture = 59;
}
/**
* Returns the block texture based on the side being looked at. Args: side
*/
/**
* Called upon block activation (left or right click on the block.). The three integers represent x,y,z of the
* block.
*/
public boolean blockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
{
if (par1World.isRemote)
{
return true;
}
else
{
ModLoader.getMinecraftInstance().displayGuiScreen(new GuiCrafting2(par5EntityPlayer.inventory, par1World, par2, par3, par4));
return true;
}
}
}
Now finally we need a function to put in our mod_file that will create recipes in our CraftingManger2 file
Here's an edited copy with code tags and everything.
this is a tutorial on how to make a new block that just just like a crafting table, except it has custom recipies that dont work in a normal crafting table
1. create a new block in your mod_file
2. you need to create a new crafting manager, i call mine CraftingManager2
CraftingManager2/only recipies that use all vanilla items can be put in this file, recipies useing mod items will be in another file we create later
Next we need to create a file called RecipieSorter2
This file tells crafting manager 2 what a recipie is.
package net.minecraft.src;
import java.util.Comparator;
class RecipeSorter2 implements Comparator
{
final CraftingManager2 CraftingManager2;
RecipeSorter2(CraftingManager2 par1CraftingManager2)
{
CraftingManager2 = par1CraftingManager2;
}
public int compareRecipes(IRecipe par1IRecipe, IRecipe par2IRecipe)
{
if ((par1IRecipe instanceof ShapelessRecipes) && (par2IRecipe instanceof ShapedRecipes))
{
return 1;
}
if ((par2IRecipe instanceof ShapelessRecipes) && (par1IRecipe instanceof ShapedRecipes))
{
return -1;
}
if (par2IRecipe.getRecipeSize() < par1IRecipe.getRecipeSize())
{
return -1;
}
return par2IRecipe.getRecipeSize() <= par1IRecipe.getRecipeSize() ? 0 : 1;
}
public int compare(Object par1Obj, Object par2Obj)
{
return compareRecipes((IRecipe)par1Obj, (IRecipe)par2Obj);
}
}
now we need to make a ContainerCrafting2 file that helps with our gui
note about replacing NameHereBlock with your block
package net.minecraft.src;
import java.util.List;
public class ContainerWorkbench2 extends Container
{
/** The crafting matrix inventory (3x3). */
public InventoryCrafting craftMatrix;
public IInventory craftResult;
private World worldObj;
private int posX;
private int posY;
private int posZ;
public ContainerWorkbench2(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5)
{
craftMatrix = new InventoryCrafting(this, 3, 3);
craftResult = new InventoryCraftResult();
worldObj = par2World;
posX = par3;
posY = par4;
posZ = par5;
addSlot(new SlotCrafting(par1InventoryPlayer.player, craftMatrix, craftResult, 0, 124, 35));
for (int i = 0; i < 3; i++)
{
for (int l = 0; l < 3; l++)
{
addSlot(new Slot(craftMatrix, l + i * 3, 30 + l * 18, 17 + i * 18));
}
}
for (int j = 0; j < 3; j++)
{
for (int i1 = 0; i1 < 9; i1++)
{
addSlot(new Slot(par1InventoryPlayer, i1 + j * 9 + 9, 8 + i1 * 18, 84 + j * 18));
}
}
for (int k = 0; k < 9; k++)
{
addSlot(new Slot(par1InventoryPlayer, k, 8 + k * 18, 142));
}
onCraftMatrixChanged(craftMatrix);
}
/**
* Callback for when the crafting matrix is changed.
*/
public void onCraftMatrixChanged(IInventory par1IInventory)
{
craftResult.setInventorySlotContents(0, CraftingManager2.getInstance().findMatchingRecipe(craftMatrix));
}
/**
* Callback for when the crafting gui is closed.
*/
public void onCraftGuiClosed(EntityPlayer par1EntityPlayer)
{
super.onCraftGuiClosed(par1EntityPlayer);
if (worldObj.isRemote)
{
return;
}
for (int i = 0; i < 9; i++)
{
ItemStack itemstack = craftMatrix.getStackInSlotOnClosing(i);
if (itemstack != null)
{
par1EntityPlayer.dropPlayerItem(itemstack);
}
}
}
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
{
//change this block to whatever the block you made in your mod_file
if (worldObj.getBlockId(posX, posY, posZ) != mod_NameHere.NameHere.blockID)
{
return false;
}
return par1EntityPlayer.getDistanceSq((double)posX + 0.5D, (double)posY + 0.5D, (double)posZ + 0.5D) <= 64D;
}
/**
* Called to transfer a stack from one inventory to the other eg. when shift clicking.
*/
public ItemStack transferStackInSlot(int par1)
{
ItemStack itemstack = null;
Slot slot = (Slot)inventorySlots.get(par1);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (par1 == 0)
{
if (!mergeItemStack(itemstack1, 10, 46, true))
{
return null;
}
slot.func_48433_a(itemstack1, itemstack);
}
else if (par1 >= 10 && par1 < 37)
{
if (!mergeItemStack(itemstack1, 37, 46, false))
{
return null;
}
}
else if (par1 >= 37 && par1 < 46)
{
if (!mergeItemStack(itemstack1, 10, 37, false))
{
return null;
}
}
else if (!mergeItemStack(itemstack1, 10, 46, false))
{
return null;
}
if (itemstack1.stackSize == 0)
{
slot.putStack(null);
}
else
{
slot.onSlotChanged();
}
if (itemstack1.stackSize != itemstack.stackSize)
{
slot.onPickupFromSlot(itemstack1);
}
else
{
return null;
}
}
return itemstack;
}
}
now we need to make our gui for when we open our crafting table/this is called GuiCrafting2
the image needs to be in minecrafts gui file found in the minecraft .jar
package net.minecraft.src;
import net.minecraft.client.Minecraft;
import org.lwjgl.opengl.GL11;
public class GuiCrafting2 extends GuiContainer
{
public GuiCrafting2(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5)
{
super(new ContainerWorkbench2(par1InventoryPlayer, par2World, par3, par4, par5));
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
super.onGuiClosed();
}
/**
* Draw the foreground layer for the GuiContainer (everythin in front of the items)
*/
protected void drawGuiContainerForegroundLayer()
{
fontRenderer.drawString(StatCollector.translateToLocal("container.crafting"), 28, 6, 0x404040);
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
}
/**
* Draw the background layer for the GuiContainer (everything behind the items)
*/
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int i = mc.renderEngine.getTexture("/gui/DnaMixing.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(i);
int j = (width - xSize) / 2;
int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
}
}
next we need our custom block file that will tell minecraft to open our gui
package net.minecraft.src;
public class BlockCraftingTable2 extends Block
{
protected BlockCraftingTable2(int par1)
{
super(par1, Material.wood);
blockIndexInTexture = 59;
}
/**
* Returns the block texture based on the side being looked at. Args: side
*/
/**
* Called upon block activation (left or right click on the block.). The three integers represent x,y,z of the
* block.
*/
public boolean blockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
{
if (par1World.isRemote)
{
return true;
}
else
{
ModLoader.getMinecraftInstance().displayGuiScreen(new GuiCrafting2(par5EntityPlayer.inventory, par1World, par2, par3, par4));
return true;
}
}
}
Now finally we need a function to put in our mod_file that will create recipes in our CraftingManger2 file
put this after all of your public items but before public void load
now we need a recipie template note this isn't a modloader recipie but an addDnaMixing recipie
addDnaMixing(new ItemStack(mod_Biology.GeneticallyEngineeredEggCowCow, 1), new Object[] {
"CEC", Character.valueOf('E'), Item.egg, Character.valueOf('C'), mod_Biology.DnaFilledDartCow
});
i hope this helped this is my first tutorial and i am not the best at explaining things
Rollback Post to RevisionRollBack
Author of the Clarity, Serenity, Sapphire & Halcyon shader packs for Minecraft: Java Edition.
1. create a new block in your mod_file
2. you need to create a new crafting manager, i call mine CraftingManager2
CraftingManager2/only recipies that use all vanilla items can be put in this file, recipies useing mod items will be in another file we create later
[code]package net.minecraft.src; import java.io.PrintStream; import java.util.*; public class CraftingManager2 { /** The static instance of this class */ private static final CraftingManager2 instance = new CraftingManager2(); /** A list of all the recipes added */ private List recipes; /** * Returns the static instance of this class */ public static final CraftingManager2 getInstance() { return instance; } private CraftingManager2() { recipes = new ArrayList(); addRecipe(new ItemStack(Item.paper, 3), new Object[] { "###", '#', Item.reed }); addRecipe(new ItemStack(mod_Biology.GeneticallyEngineeredEggCowCow, 1), new Object[] { "C", "E", "C", 'E', Item.egg, 'C', mod_Biology.DnaFilledDartCow }); Collections.sort(recipes, new RecipeSorter2(this)); System.out.println((new StringBuilder()).append(recipes.size()).append(" recipes").toString()); } /** * Adds a recipe. See spreadsheet on first page for details. */ void addRecipe(ItemStack par1ItemStack, Object par2ArrayOfObj[]) { String s = ""; int i = 0; int j = 0; int k = 0; if (par2ArrayOfObj[i] instanceof String[]) { String as[] = (String[])par2ArrayOfObj[i++]; for (int l = 0; l < as.length; l++) { String s2 = as[l]; k++; j = s2.length(); s = (new StringBuilder()).append(s).append(s2).toString(); } } else { while (par2ArrayOfObj[i] instanceof String) { String s1 = (String)par2ArrayOfObj[i++]; k++; j = s1.length(); s = (new StringBuilder()).append(s).append(s1).toString(); } } HashMap hashmap = new HashMap(); for (; i < par2ArrayOfObj.length; i += 2) { Character character = (Character)par2ArrayOfObj[i]; ItemStack itemstack = null; if (par2ArrayOfObj[i + 1] instanceof Item) { itemstack = new ItemStack((Item)par2ArrayOfObj[i + 1]); } else if (par2ArrayOfObj[i + 1] instanceof Block) { itemstack = new ItemStack((Block)par2ArrayOfObj[i + 1], 1, -1); } else if (par2ArrayOfObj[i + 1] instanceof ItemStack) { itemstack = (ItemStack)par2ArrayOfObj[i + 1]; } hashmap.put(character, itemstack); } ItemStack aitemstack[] = new ItemStack[j * k]; for (int i1 = 0; i1 < j * k; i1++) { char c = s.charAt(i1); if (hashmap.containsKey(Character.valueOf©)) { aitemstack[i1] = ((ItemStack)hashmap.get(Character.valueOf©)).copy(); } else { aitemstack[i1] = null; } } recipes.add(new ShapedRecipes(j, k, aitemstack, par1ItemStack)); } void addShapelessRecipe(ItemStack par1ItemStack, Object par2ArrayOfObj[]) { ArrayList arraylist = new ArrayList(); Object aobj[] = par2ArrayOfObj; int i = aobj.length; for (int j = 0; j < i; j++) { Object obj = aobj[j]; if (obj instanceof ItemStack) { arraylist.add(((ItemStack)obj).copy()); continue; } if (obj instanceof Item) { arraylist.add(new ItemStack((Item)obj)); continue; } if (obj instanceof Block) { arraylist.add(new ItemStack((Block)obj)); } else { throw new RuntimeException("Invalid shapeless recipy!"); } } recipes.add(new ShapelessRecipes(par1ItemStack, arraylist)); } public ItemStack findMatchingRecipe(InventoryCrafting par1InventoryCrafting) { int i = 0; ItemStack itemstack = null; ItemStack itemstack1 = null; for (int j = 0; j < par1InventoryCrafting.getSizeInventory(); j++) { ItemStack itemstack2 = par1InventoryCrafting.getStackInSlot(j); if (itemstack2 == null) { continue; } if (i == 0) { itemstack = itemstack2; } if (i == 1) { itemstack1 = itemstack2; } i++; } if (i == 2 && itemstack.itemID == itemstack1.itemID && itemstack.stackSize == 1 && itemstack1.stackSize == 1 && Item.itemsList[itemstack.itemID].isDamageable()) { Item item = Item.itemsList[itemstack.itemID]; int l = item.getMaxDamage() - itemstack.getItemDamageForDisplay(); int i1 = item.getMaxDamage() - itemstack1.getItemDamageForDisplay(); int j1 = l + i1 + (item.getMaxDamage() * 10) / 100; int k1 = item.getMaxDamage() - j1; if (k1 < 0) { k1 = 0; } return new ItemStack(itemstack.itemID, 1, k1); } for (int k = 0; k < recipes.size(); k++) { IRecipe irecipe = (IRecipe)recipes.get(k); if (irecipe.matches(par1InventoryCrafting)) { return irecipe.getCraftingResult(par1InventoryCrafting); } } return null; } /** * returns the List<> of all recipes */ public List getRecipeList() { return recipes; } }[/code]
Next we need to create a file called RecipieSorter2
This file tells crafting manager 2 what a recipie is.
package net.minecraft.src;
import java.util.Comparator;
class RecipeSorter2 implements Comparator
{
final CraftingManager2 CraftingManager2;
RecipeSorter2(CraftingManager2 par1CraftingManager2)
{
CraftingManager2 = par1CraftingManager2;
}
public int compareRecipes(IRecipe par1IRecipe, IRecipe par2IRecipe)
{
if ((par1IRecipe instanceof ShapelessRecipes) && (par2IRecipe instanceof ShapedRecipes))
{
return 1;
}
if ((par2IRecipe instanceof ShapelessRecipes) && (par1IRecipe instanceof ShapedRecipes))
{
return -1;
}
if (par2IRecipe.getRecipeSize() < par1IRecipe.getRecipeSize())
{
return -1;
}
return par2IRecipe.getRecipeSize() <= par1IRecipe.getRecipeSize() ? 0 : 1;
}
public int compare(Object par1Obj, Object par2Obj)
{
return compareRecipes((IRecipe)par1Obj, (IRecipe)par2Obj);
}
}
now we need to make a ContainerCrafting2 file that helps with our gui
note about replacing NameHereBlock with your block
package net.minecraft.src;
import java.util.List;
public class ContainerWorkbench2 extends Container
{
/** The crafting matrix inventory (3x3). */
public InventoryCrafting craftMatrix;
public IInventory craftResult;
private World worldObj;
private int posX;
private int posY;
private int posZ;
public ContainerWorkbench2(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5)
{
craftMatrix = new InventoryCrafting(this, 3, 3);
craftResult = new InventoryCraftResult();
worldObj = par2World;
posX = par3;
posY = par4;
posZ = par5;
addSlot(new SlotCrafting(par1InventoryPlayer.player, craftMatrix, craftResult, 0, 124, 35));
for (int i = 0; i < 3; i++)
{
for (int l = 0; l < 3; l++)
{
addSlot(new Slot(craftMatrix, l + i * 3, 30 + l * 18, 17 + i * 18));
}
}
for (int j = 0; j < 3; j++)
{
for (int i1 = 0; i1 < 9; i1++)
{
addSlot(new Slot(par1InventoryPlayer, i1 + j * 9 + 9, 8 + i1 * 18, 84 + j * 18));
}
}
for (int k = 0; k < 9; k++)
{
addSlot(new Slot(par1InventoryPlayer, k, 8 + k * 18, 142));
}
onCraftMatrixChanged(craftMatrix);
}
/**
* Callback for when the crafting matrix is changed.
*/
public void onCraftMatrixChanged(IInventory par1IInventory)
{
craftResult.setInventorySlotContents(0, CraftingManager2.getInstance().findMatchingRecipe(craftMatrix));
}
/**
* Callback for when the crafting gui is closed.
*/
public void onCraftGuiClosed(EntityPlayer par1EntityPlayer)
{
super.onCraftGuiClosed(par1EntityPlayer);
if (worldObj.isRemote)
{
return;
}
for (int i = 0; i < 9; i++)
{
ItemStack itemstack = craftMatrix.getStackInSlotOnClosing(i);
if (itemstack != null)
{
par1EntityPlayer.dropPlayerItem(itemstack);
}
}
}
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
{
//change this block to whatever the block you made in your mod_file
if (worldObj.getBlockId(posX, posY, posZ) != mod_NameHere.NameHere.blockID)
{
return false;
}
return par1EntityPlayer.getDistanceSq((double)posX + 0.5D, (double)posY + 0.5D, (double)posZ + 0.5D) <= 64D;
}
/**
* Called to transfer a stack from one inventory to the other eg. when shift clicking.
*/
public ItemStack transferStackInSlot(int par1)
{
ItemStack itemstack = null;
Slot slot = (Slot)inventorySlots.get(par1);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (par1 == 0)
{
if (!mergeItemStack(itemstack1, 10, 46, true))
{
return null;
}
slot.func_48433_a(itemstack1, itemstack);
}
else if (par1 >= 10 && par1 < 37)
{
if (!mergeItemStack(itemstack1, 37, 46, false))
{
return null;
}
}
else if (par1 >= 37 && par1 < 46)
{
if (!mergeItemStack(itemstack1, 10, 37, false))
{
return null;
}
}
else if (!mergeItemStack(itemstack1, 10, 46, false))
{
return null;
}
if (itemstack1.stackSize == 0)
{
slot.putStack(null);
}
else
{
slot.onSlotChanged();
}
if (itemstack1.stackSize != itemstack.stackSize)
{
slot.onPickupFromSlot(itemstack1);
}
else
{
return null;
}
}
return itemstack;
}
}
[CODE]
now we need to make our gui for when we open our crafting table/this is called GuiCrafting2
the image needs to be in minecrafts gui file found in the minecraft .jar
package net.minecraft.src;
import net.minecraft.client.Minecraft;
import org.lwjgl.opengl.GL11;
public class GuiCrafting2 extends GuiContainer
{
public GuiCrafting2(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5)
{
super(new ContainerWorkbench2(par1InventoryPlayer, par2World, par3, par4, par5));
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
super.onGuiClosed();
}
/**
* Draw the foreground layer for the GuiContainer (everythin in front of the items)
*/
protected void drawGuiContainerForegroundLayer()
{
fontRenderer.drawString(StatCollector.translateToLocal("container.crafting"), 28, 6, 0x404040);
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
}
/**
* Draw the background layer for the GuiContainer (everything behind the items)
*/
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int i = mc.renderEngine.getTexture("/gui/DnaMixing.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(i);
int j = (width - xSize) / 2;
int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
}
}
next we need our custom block file that will tell minecraft to open our gui
package net.minecraft.src;
public class BlockCraftingTable2 extends Block
{
protected BlockCraftingTable2(int par1)
{
super(par1, Material.wood);
blockIndexInTexture = 59;
}
/**
* Returns the block texture based on the side being looked at. Args: side
*/
/**
* Called upon block activation (left or right click on the block.). The three integers represent x,y,z of the
* block.
*/
public boolean blockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
{
if (par1World.isRemote)
{
return true;
}
else
{
ModLoader.getMinecraftInstance().displayGuiScreen(new GuiCrafting2(par5EntityPlayer.inventory, par1World, par2, par3, par4));
return true;
}
}
}
Now finally we need a function to put in our mod_file that will create recipes in our CraftingManger2 file
public static void addDnaMixing(ItemStack itemstack, Object aobj[])
{
CraftingManager2.getInstance().addRecipe(itemstack, aobj);
}
put this after all of your public items but before public void load
now we need a recipie template note this isn't a modloader recipie but an addDnaMixing recipie
addDnaMixing(new ItemStack(mod_Biology.GeneticallyEngineeredEggCowCow, 1), new Object[] {
"CEC", Character.valueOf('E'), Item.egg, Character.valueOf('C'), mod_Biology.DnaFilledDartCow
});
i hope this helped this is my first tutorial and i am not the best at explaining things
Be sure to check out my texture pack: Easy Ores!
this is a tutorial on how to make a new block that just just like a crafting table, except it has custom recipies that dont work in a normal crafting table
1. create a new block in your mod_file
2. you need to create a new crafting manager, i call mine CraftingManager2
CraftingManager2/only recipies that use all vanilla items can be put in this file, recipies useing mod items will be in another file we create later
Next we need to create a file called RecipieSorter2
This file tells crafting manager 2 what a recipie is.
now we need to make a ContainerCrafting2 file that helps with our gui
note about replacing NameHereBlock with your block
now we need to make our gui for when we open our crafting table/this is called GuiCrafting2
the image needs to be in minecrafts gui file found in the minecraft .jar
Now finally we need a function to put in our mod_file that will create recipes in our CraftingManger2 file
put this after all of your public items but before public void load
now we need a recipie template note this isn't a modloader recipie but an addDnaMixing recipie
addDnaMixing(new ItemStack(mod_Biology.GeneticallyEngineeredEggCowCow, 1), new Object[] {
"CEC", Character.valueOf('E'), Item.egg, Character.valueOf('C'), mod_Biology.DnaFilledDartCow
});
i hope this helped this is my first tutorial and i am not the best at explaining things
Author of the Clarity, Serenity, Sapphire & Halcyon shader packs for Minecraft: Java Edition.
My Github page.
The entire Minecraft shader development community now has its own Discord server! Feel free to join and chat with all the developers!
you need to change it from
addDnaMixing
to
mod_yourmodnamehere.addDnaMixing
also
addRecipe is now this.func_92103_a
and
addShapelessRecipe is this.addShapelessRecipe