I am need help with coding a Mod I am creating called ColoredCobblestone. I need to add MetaData to dyes. I already created Black Cobblestone, but all that needed was Item.dyePowder not like Item.dyePowder, 1, 4 what do I do? Thanks! PLEASE HELP!
*** Here is the Code - There is a error on , after Character.valueOf(' B ') ***
package net.minecraft.src;
import java.util.Random;
public class mod_ColoredCobblestone extends BaseMod
{
public static final Block BlackCobblestone = new Block (220, Material.rock).setHardness(2.0F).setLightValue(0.5F).setResistance(10.0F).setBlockName("C").setCreativeTab(CreativeTabs.tabBlock);
public static final Block BlueCobblestone = new Block (220, Material.rock).setHardness(2.0F).setLightValue(0.5F).setResistance(10.0F).setBlockName("Co").setCreativeTab(CreativeTabs.tabBlock);
public void load()
{
BlackCobblestone.blockIndexInTexture = ModLoader.addOverride("/terrain.png" , "/BlackCobblestone.png");
ModLoader.addName(BlackCobblestone, "Black Cobblestone");
ModLoader.registerBlock(BlackCobblestone);
ModLoader.addRecipe(new ItemStack(BlackCobblestone,1), new Object[]{
"AB", Character.valueOf('A'), (Item.dyePowder), Character.valueOf('B'), Block.cobblestone});
BlueCobblestone.blockIndexInTexture = ModLoader.addOverride("/terrain.png" , "/BlueCobblestone.png");
ModLoader.addName(BlueCobblestone, "Blue Cobblestone");
ModLoader.registerBlock(BlueCobblestone);
ModLoader.addRecipe(new ItemStack(BlueCobblestone,1), new Object[]{
"AB", Character.valueOf('A'), Block.cobblestone}); Character.valueOf('B'), new ItemStack(Item.dyePowder, 1, 4);
}
public String getVersion()
{
return "1.4.7";
}}
*** Here is the Crash Report from the MC Client ***
Minecraft has crashed!
----------------------
Minecraft has stopped running because it encountered a problem; Exception occured in ModLoader
A full error report has been saved to C:\Users\Joshua\Desktop\Joshua\Test Mod\jars\.\crash-reports\crash-2013-02-18_01.06.36-client.txt - Please include a copy of that file (Not this screen!) if you report this crash to anyone; without it, they will not be able to help fix the crash
--- BEGIN ERROR REPORT a74e3877 --------
Full report at:
C:\Users\Joshua\Desktop\Joshua\Test Mod\jars\.\crash-reports\crash-2013-02-18_01.06.36-client.txt
Please show that file to Mojang, NOT just this screen!
Generated 2/18/13 1:06 AM
-- System Details --
Details:
Minecraft Version: 1.4.7
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.7.0_07, Oracle Corporation
Java VM Version: Java HotSpotâ„¢ 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 955817504 bytes (911 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Suspicious classes: Start[net.minecraft.src.IPlayerUsage, MinecraftFakeLauncher, ThreadShutdown, ...]
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
ModLoader: Mods loaded: 1
ModLoader 1.4.7
java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at net.minecraft.src.ModLoader.addMod(ModLoader.java:395)
at net.minecraft.src.ModLoader.readFromClassPath(ModLoader.java:1406)
at net.minecraft.src.ModLoader.init(ModLoader.java:952)
at net.minecraft.src.ModLoader.addAllRenderers(ModLoader.java:190)
at net.minecraft.src.RenderManager.<init>(RenderManager.java:93)
at net.minecraft.src.RenderManager.<clinit>(RenderManager.java:14)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:421)
at net.minecraft.src.MinecraftAppletImpl.startGame(MinecraftAppletImpl.java:41)
at net.minecraft.client.Minecraft.run(Minecraft.java:741)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Slot 220 is already occupied by net.minecraft.src.Block@57c40f51 when adding net.minecraft.src.Block@8c9bbdb
at net.minecraft.src.Block.<init>(Block.java:282)
at net.minecraft.src.mod_ColoredCobblestone.<clinit>(mod_ColoredCobblestone.java:8)
... 16 more
--- END ERROR REPORT a389b73b ----------
You registry both blocks as ID 220, but you aren't adding any metadata-value (also called damagevalue):
public static final Block BlackCobblestone = new Block (220, Material.rock)...
public static final Block BlueCobblestone = new Block (220, Material.rock)...
Take a look into BlockCloth to see howto do it!
package net.minecraft.block;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
public class BlockCloth extends Block
{
@SideOnly(Side.CLIENT)
private Icon[] field_94349_a;
public BlockCloth()
{
super(35, Material.cloth);
this.setCreativeTab(CreativeTabs.tabBlock);
}
@SideOnly(Side.CLIENT)
/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
*/
public Icon getBlockTextureFromSideAndMetadata(int par1, int par2)
{
return this.field_94349_a[par2];
}
/**
* Determines the damage on the item the block drops. Used in cloth and wood.
*/
public int damageDropped(int par1)
{
return par1;
}
/**
* Takes a dye damage value and returns the block damage value to match
*/
public static int getBlockFromDye(int par0)
{
return ~par0 & 15;
}
/**
* Takes a block damage value and returns the dye damage value to match
*/
public static int getDyeFromBlock(int par0)
{
return ~par0 & 15;
}
@SideOnly(Side.CLIENT)
/**
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
*/
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (int j = 0; j < 16; ++j)
{
par3List.add(new ItemStack(par1, 1, j));
}
}
@SideOnly(Side.CLIENT)
public void func_94332_a(IconRegister par1IconRegister)
{
this.field_94349_a = new Icon[16];
for (int i = 0; i < this.field_94349_a.length; ++i)
{
this.field_94349_a[i] = par1IconRegister.func_94245_a("cloth_" + i);
}
}
}
And to your crafting-recipe-registry error:
ModLoader.addRecipe(new ItemStack(BlueCobblestone,1), new Object[]{
"AB", Character.valueOf('A'), Block.cobblestone}); Character.valueOf('B'), new ItemStack(Item.dyePowder, 1, 4);
There is a "});" after your Block.cobblestone, but it should be at the end of the line like this:
ModLoader.addRecipe(new ItemStack(BlueCobblestone,1), new Object[]{
"AB", Character.valueOf('A'), Block.cobblestone, Character.valueOf('B'),new ItemStack(Item.dyePowder,1,4)});
You registry both blocks as ID 220, but you aren't adding any metadata-value (also called damagevalue):
Make it :
public static final Block BlackCobblestone = new Block (220, Material.rock)...
public static final Block BlueCobblestone = new Block ([b]221[/b], Material.rock)...
Can someone please figure out how to do this as Cyphrags is suggesting? I am trying to do the same thing with stairs. I want to create wool stairs of all colors and I would prefer to do it by creating only one new block rather than creating 16 new blocks. I am also having issues figuring out how to use the dye recipes for this method. I am very new to java and this is my first attempt at modding. I am aware that there is already a mod that does what I am trying to do, but I would like to learn how to do it myself so that I can eventually start making more advanced mods.
Also, I have tried simply creating 16 new blocks for each of the colored wool stairs, by adding the following line of code to the Block.java:
public static final Block stairsClothWhite = (new BlockStairs(159, cloth, 0)).setHardness(0.8F).setStepSound(soundClothFootstep).setUnlocalizedName("stairsClothWhite");
I did this 16 times, changing the metaData for color each time. However, the problem with this is that I cannot figure out the recipe to craft the stairs from different colored cloths (since there is only one cloth block). If I try to craft stairs from blue wool or orange wool or any color wool, I always end up with white wool stairs.
I tried copying the dye recipe for cloth which can be found in RecipesDyes.java:
for (int var2 = 0; var2 < 16; ++var2)
{
par1CraftingManager.addShapelessRecipe(new ItemStack(Block.cloth, 1, BlockCloth.getDyeFromBlock(var2)), new Object[] {new ItemStack(Item.dyePowder, 1, var2), new ItemStack(Item.itemsList[Block.cloth.blockID], 1, 0)});
}
I modified this code to use and produce stairsCloth rather than cloth, but there is no way to make this work with 16 separate stair blocks.
*** Here is the Code - There is a error on , after Character.valueOf(' B ') ***
*** Here is the Crash Report from the MC Client ***
Minecraft has crashed!
----------------------
Minecraft has stopped running because it encountered a problem; Exception occured in ModLoader
A full error report has been saved to C:\Users\Joshua\Desktop\Joshua\Test Mod\jars\.\crash-reports\crash-2013-02-18_01.06.36-client.txt - Please include a copy of that file (Not this screen!) if you report this crash to anyone; without it, they will not be able to help fix the crash
--- BEGIN ERROR REPORT a74e3877 --------
Full report at:
C:\Users\Joshua\Desktop\Joshua\Test Mod\jars\.\crash-reports\crash-2013-02-18_01.06.36-client.txt
Please show that file to Mojang, NOT just this screen!
Generated 2/18/13 1:06 AM
-- System Details --
Details:
Minecraft Version: 1.4.7
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.7.0_07, Oracle Corporation
Java VM Version: Java HotSpotâ„¢ 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 955817504 bytes (911 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Suspicious classes: Start[net.minecraft.src.IPlayerUsage, MinecraftFakeLauncher, ThreadShutdown, ...]
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
ModLoader: Mods loaded: 1
ModLoader 1.4.7
java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at net.minecraft.src.ModLoader.addMod(ModLoader.java:395)
at net.minecraft.src.ModLoader.readFromClassPath(ModLoader.java:1406)
at net.minecraft.src.ModLoader.init(ModLoader.java:952)
at net.minecraft.src.ModLoader.addAllRenderers(ModLoader.java:190)
at net.minecraft.src.RenderManager.<init>(RenderManager.java:93)
at net.minecraft.src.RenderManager.<clinit>(RenderManager.java:14)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:421)
at net.minecraft.src.MinecraftAppletImpl.startGame(MinecraftAppletImpl.java:41)
at net.minecraft.client.Minecraft.run(Minecraft.java:741)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Slot 220 is already occupied by net.minecraft.src.Block@57c40f51 when adding net.minecraft.src.Block@8c9bbdb
at net.minecraft.src.Block.<init>(Block.java:282)
at net.minecraft.src.mod_ColoredCobblestone.<clinit>(mod_ColoredCobblestone.java:8)
... 16 more
--- END ERROR REPORT a389b73b ----------
Take a look into BlockCloth to see howto do it!
And to your crafting-recipe-registry error:
ModLoader.addRecipe(new ItemStack(BlueCobblestone,1), new Object[]{
"AB", Character.valueOf('A'), Block.cobblestone}); Character.valueOf('B'), new ItemStack(Item.dyePowder, 1, 4);
There is a "});" after your Block.cobblestone, but it should be at the end of the line like this:
ModLoader.addRecipe(new ItemStack(BlueCobblestone,1), new Object[]{
"AB", Character.valueOf('A'), Block.cobblestone, Character.valueOf('B'),new ItemStack(Item.dyePowder,1,4)});
Make it :
I think he wants it to be like wool, so 1 Block-ID (220) and 16 different metadatavalues
Also, I have tried simply creating 16 new blocks for each of the colored wool stairs, by adding the following line of code to the Block.java:
I did this 16 times, changing the metaData for color each time. However, the problem with this is that I cannot figure out the recipe to craft the stairs from different colored cloths (since there is only one cloth block). If I try to craft stairs from blue wool or orange wool or any color wool, I always end up with white wool stairs.
I tried copying the dye recipe for cloth which can be found in RecipesDyes.java:
I modified this code to use and produce stairsCloth rather than cloth, but there is no way to make this work with 16 separate stair blocks.