[1.8.1] Block
+6
ikke009
noctisbeta
mastereric
bottz2
TheCodeNewbie
Strengthowns
10 posters
MC Modding :: Modding :: Singleplayer Modding :: Tutorials
Page 1 of 1
[1.8.1] Block
Block
- Spoiler:
- BlockNamehere
- Code:
package net.minecraft.src;
import java.util.Random;
public class BlockNamehere extends Block
{
public BlockNamehere(int i, int j)
{
super(i, j, Material.ground);
}
public int idDropped(int i, Random random)
{
return mod_Namehere.Namehere.blockID;
}
public int quantityDropped(Random random)
{
return 3;
}
}
mod_Namehere- Code:
package net.minecraft.src;
public class mod_Namehere extends BaseMod
{
public static Block Namehere = new BlockNamehere(190, 0).setHardness(1.0F).setResistance(6000.0F).setLightValue(1.0F).setBlockName("Namehere");
public String Version()
{
return "1.8.1";
}
public mod_Namehere()
{
ModLoader.RegisterBlock(Namehere);
Namehere.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/Namehere.png");
ModLoader.AddName(Namehere, "Namehere");
ModLoader.AddRecipe(new ItemStack(Namehere, 1), new Object[] {
"###", "###", "###", Character.valueOf('#'), Item.redstone
});
}
}
Help: BlockNamehere
- Firstly, if you want to use some functions for your block, then have a look in "Block.java".
1. The line with this:- Code:
super(i, j, Material.ground);
- Code:
//FOR MORE STATS ON THESE MATERIALS, LOOK AT THE BOTTOM OF "Material.java".
Material air; //You probably shouldn't use this one.
Material grass; //Pretty much the same as ground.
Material ground; //The block can be harvested when broken using this one.
Material wood; //It can be set on fire.
Material rock; // It can only be harvested with a pickaxe.
Material iron; // Can only be harvested with an iron pick or better.
Material water; //You probably shouldn't use this one.
Material lava; //You probably shouldn't use this one.
Material leaves; //It can burn.
Material plants; //You probably shouldn't use this one.
Material vine; //It can burn.
Material sponge; //You probably shouldn't use this one.
Material cloth; //It can burn.
Material fire; //You probably shouldn't use this one.
Material sand; //You probably shouldn't use this one.
Material circuits; //You probably shouldn't use this one.
Material glass; //You probably shouldn't use this one.
Material tnt; //You probably shouldn't use this one.
Material unused; //You probably shouldn't use this one.
Material ice; //You probably shouldn't use this one.
Material snow; //You probably shouldn't use this one.
Material craftedSnow; //You probably shouldn't use this one.
Material cactus; //You probably shouldn't use this one.
Material clay; //You probably shouldn't use this one.
Material pumpkin; //You probably shouldn't use this one.
Material portal; //You probably shouldn't use this one.
Material cakeMaterial; //You probably shouldn't use this one.
Material web; //You probably shouldn't use this one. Means it isn't solid.
Material piston; //You probably shouldn't use this one.
The main ones you need should use are the ground, rock and iron ones.
2. At this part:- Code:
return mod_Namehere.Namehere.blockID;
- Code:
return Item.redstone.shiftedIndex;
- Code:
return Block.dirt.blockID;
3. For the bit like this:- Code:
return 3;
4. Navigate to this sort of path: "MCP\src\minecraft\net\minecraft\src" and save a copy of your file in there with the ".java" extension.Help: mod_Namehere
1. This bit:- Code:
new BlockNamehere(190,
2.- Code:
.setHardness(1.0F)
3.- Code:
.setResistance(6000.0F)
4.- Code:
.setLightValue(1.0F)
5.- Code:
.setBlockName("Namehere")
6. At this part:- Code:
return "1.8.1";
7.- Code:
ModLoader.RegisterBlock(Namehere);
8.- Code:
Namehere.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/Namehere.png");
9.- Code:
ModLoader.AddName(Namehere, "Nameingamehere");
10. To explain the "ModLoader.AddRecipe" part. The "Namehere" word is what you get from crafting it, and the 1 is how many of it you get. Each set of "###" bits are 3 spaces across in the crafting grid. Then it's saying that "If the character is the # symbol, make it equal to redstone for when crafting".
[size="4"]SMP Block[/size]
- Spoiler:
- BlockNamehere
- Code:
mod_Namehere- Code:
Help: BlockNamehere
1.Help: mod_Namehere
1.
Re: [1.8.1] Block
I posted this in the mc forums but no one replied so yeah, I'm getting this error when I try to recompile my block files:
EDIT: I fixed the second error, it just need an opening bracket.... derp. Would still appreciate any help on the first error =D
- Code:
== MCP v4.4 ==
> Recompiling client...
"C:\Program Files (x86)\Java\jdk1.7.0\bin\javac.exe" -g -source 1.6 -target 1.6
-classpath "lib/;lib/*;jars/bin/minecraft.jar;jars/bin/jinput.jar;jars/bin/lwjgl
.jar;jars/bin/lwjgl_util.jar" -sourcepath src/minecraft -d bin/minecraft src/min
ecraft\net\minecraft\client\*.java src/minecraft\net\minecraft\isom\*.java src/m
inecraft\net\minecraft\src\*.java conf/patches/*.java failed.
Return code : 1
== ERRORS FOUND ==
warning: [options] bootstrap class path not set in conjunction with -source 1.6
src\minecraft\net\minecraft\src\Blockburner.java:8: error: invalid method declar
ation; return type required
public Blockburner(int i, int j)
^
src\minecraft\net\minecraft\src\mod_burner.java:12: error: <identifier> expected
public mod_burner)
^
2 errors
1 warning
==================
> Done in 2.31 seconds
> Recompiling server...
!! Can not find server sources !!
Press any key to continue . . .
EDIT: I fixed the second error, it just need an opening bracket.... derp. Would still appreciate any help on the first error =D
TheCodeNewbie- Member
- Posts : 6
Join date : 2011-10-25
Re: [1.8.1] Block
hey how do i make like a workbench or a chest
bottz2- Member
- Posts : 14
Join date : 2011-10-24
Re: [1.8.1] Block
Copy-paste code from the workbench/chest's class filebottz2 wrote:hey how do i make like a workbench or a chest
mastereric- Member
- Posts : 30
Join date : 2011-10-26
Re: [1.8.1] Block
How do I make a block I made drop an item I made. I watched some tutorials and it says I have to type in
return mod_namehere.itemnamehere.shiftedIndex;
But I get an error saying that my itemname cannot be resolved or is not a field.
PLEASE HELP!
return mod_namehere.itemnamehere.shiftedIndex;
But I get an error saying that my itemname cannot be resolved or is not a field.
PLEASE HELP!
noctisbeta- Member
- Posts : 4
Join date : 2011-11-03
Re: [1.8.1] Block
of course the mod_namehere needs to be changed to the filename where you registered the item, and itemnamehere needs to be changed to the name of the item.
ikke009- Member
- Posts : 65
Join date : 2011-10-24
Age : 30
Location : The netherlands
Re: [1.8.1] Block
That's ok. I got it working, thanks! Now does anyone know what a "nullpointeexecption" is? A pro said it's the fault of my crashes and I don't know what it is or how to fix it. I have it in 3 files so, I really don't know what to do :S
noctisbeta- Member
- Posts : 4
Join date : 2011-11-03
Re: [1.8.1] Block
just for the time being, while this is not updated, the new code in MCP for blocks is...:
- Code:
package net.minecraft.src;
package net.minecraft.src;
public class mod_Namehere extends BaseMod
{
public static Block Namehere = new BlockNamehere (190, 0).setHardness(1.0F).setResistance(100.0F).setLightValue(0.0F).setBlockName("Namehere ");
public String getVersion()
{
return "1.0.0";
}
public void load()
{
}
public mod_Namehere ()
{
ModLoader.RegisterBlock(Namehere );
Namhere .blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/Namehere .png");
ModLoader.AddName(Namehere , "Namehere ");
ModLoader.AddRecipe(new ItemStack(Namehere, 1), new Object[] {
"##", "##", Character.valueOf('#'), Block.dirt
});
}
}
- Code:
package net.minecraft.src;
import java.util.Random;
public class BlockNamehere extends Block
{
public BlockNamehere(int i, int j)
{
super(i, j, Material.ground);
}
public int idDropped(int i, Random random)
{
return mod_Namhere.Namehere.shiftedIndex;
}
public int quantityDropped(Random random)
{
return 1;
}
}
jesshankin22- Member
- Posts : 47
Join date : 2011-10-24
Re: [1.8.1] Block
I get this error when I recompile can someone fix it?
BlockGreenore.java
- Code:
== ERRORS FOUND ==
src/minecraft/net/minecraft/src/BlockGreenore.java:3: class, interface, or enum expected
package net.minecraft.src;
^
1 error
==================
BlockGreenore.java
- Spoiler:
- Code:
package net.minecraft.src;
package net.minecraft.src;
public class mod_Greenore extends BaseMod
{
public static Block Greenore = new BlockGreenore (190, 0).setHardness(1.0F).setResistance(100.0F).setLightValue(0.0F).setBlockName("Greenore");
public String getVersion()
{
return "1.0.0";
}
public void load()
{
}
public mod_Greenore ()
{
ModLoader.RegisterBlock(Greenore);
Greenore.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/Greenore.png");
ModLoader.AddName(Greenore, "Greenore");
ModLoader.AddRecipe(new ItemStack(Greenore, 1), new Object[] {
"##", "##", Character.valueOf('#'), Block.dirt
});
}
}
- Spoiler:
- Code:
package net.minecraft.src;
import java.util.Random;
public class BlockGreenore extends Block
{
public BlockGreenore(int i, int j)
{
super(i, j, Material.ground);
}
public int idDropped(int i, Random random)
{
return mod_Greenore.Greenore.shiftedIndex;
}
public int quantityDropped(Random random)
{
return 1;
}
}
robinb96- Member
- Posts : 3
Join date : 2011-11-25
Re: [1.8.1] Block
oh whoops sorry I didn't post the right code... I must have gone over it twice, it should look like this...
- Code:
package net.minecraft.src;
import java.util.Random;
public class Blockrereore extends Block
{
public Blockrereore(int i, int j)
{
super(i, j, Material.ground);
}
public int idDropped(int i, Random random)
{
return mod_RERE.rereore.blockID;
}
public int quantityDropped(Random random)
{
return 1;
}
}
jesshankin22- Member
- Posts : 47
Join date : 2011-10-24
Re: [1.8.1] Block
I still get this error
- Spoiler:
- Code:
== ERRORS FOUND ==
src/minecraft/net/minecraft/src/BlockGreenore.java:3: class, interface, or enum expected
package net.minecraft.src;
^
1 error
==================
robinb96- Member
- Posts : 3
Join date : 2011-11-25
Re: [1.8.1] Block
You wrote "package net.minecraft.src;" twice.
PD: You got the files names wrong if they are the ones you wrote above each code, they should be the other way round.
PD: You got the files names wrong if they are the ones you wrote above each code, they should be the other way round.
xX_Lirianer_Xx- Member
- Posts : 2
Join date : 2011-11-14
Re: [1.8.1] Block
i think smp blocks are the same just you don't need the ModLoader.addName function in the code
Ranga179- Member
- Posts : 9
Join date : 2011-10-19
Age : 28
Similar topics
» How Do I Add A Block For 1.2.5
» [1.8.1] On/Off Light Block
» [1.8.1] Advanced Block
» [1.8.1] Explosive Block
» [unsolved]furnace like block 1.8.1/1.0.0/1.1
» [1.8.1] On/Off Light Block
» [1.8.1] Advanced Block
» [1.8.1] Explosive Block
» [unsolved]furnace like block 1.8.1/1.0.0/1.1
MC Modding :: Modding :: Singleplayer Modding :: Tutorials
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum