Okay, I posted this last page and waited a while and still have gotten no response; I have a lighting problem with some blocks I made, They emit light at 5 & 10, But for some reason are always fully lit at 15 while not lighting the sorrounding blocks that much. I had the same problem with a non-light emitting block but removing .setLightValue(XXF) fixed it but I can't do that to a block that's SUPPOSED to emit light.
Heres the code:
mod_Block.java - My only mod_ class, to clarify
/** Blocks **/
/** Ambient Stone block, emits level 5 light & blends with Dungeon Stone. **/
public static final Block Ambstone = new BlockAmbstone(160,
0).setBlockName("AmbientStone").setHardness(3F).setResistance(4F).setLightValue(10F);
/** Ambient Stone Bright block, emits level 10 light & blends with Dungeon Stone. **/
public static final Block Ambstoneb = new BlockAmbstoneb(161,
0).setBlockName("AmbientStoneBright").setHardness(3F).setResistance(4F).setLightValue(5F);
package net.minecraft.src;
import java.util.Random;
public class BlockAmbstone extends Block
{
public BlockAmbstone(int i, int j)
{
super(i, j, Material.wood);
}
public int idDropped(int i, Random random, int j)
{
return mod_Block.Ambstone.blockID;
}
public int quantityDropped(Random random)
{
return 1;
}
}
BlockAmbstoneb.java - The brighter one
package net.minecraft.src;
import java.util.Random;
public class BlockAmbstoneb extends Block
{
public BlockAmbstoneb(int i, int j)
{
super(i, j, Material.wood);
}
public int idDropped(int i, Random random, int j)
{
return mod_Block.Ambstoneb.blockID;
}
public int quantityDropped(Random random)
{
return 1;
}
}
Look at other blocks (block.java)
glowstone (lightlevel 15) has 1F
torch has 0.9...F
1F is lightlevel 15
How does this help me? I checked the code, It says 0.0-1.0F can translate to 1F to 15F. The lighting is correct, 15F is lowest, 1F is highest - the blocks are set accordingly.
Converts internally to 0-15F, this means ingame, I know how to fix this - Thanks.
Actually, no, I don't - the code says that it finds the light value by taking 15 and multiplying it by the variable you put in, So if you put in 0.2 you get 3 - This also means the value of 5 would be 0.33333333 - etc, Isn't there another way to do this?
Another question; when the game updates, How do I know what to change in my mod in order to fix it should I need to?
I found out how to make a new material, incase you wanna see click the spoiler:
How to make a new material without editing Base Classes
In the mod file there will be this for tools:
public static final Item NameherePickaxe = new ItemPickaxe(2005, EnumToolMaterial.EMERALD).setItemName("NameherePickaxe");
And this for armour:
public static final Item NamehereHelmet = new ItemArmor(1000, EnumArmorMaterial.DIAMOND, ModLoader.AddArmor("NamehereArmour"), 0).setItemName("NamehereHelmet");
or something to that effect.
All you have to do is create a new file that holds the materials and that, so make a new file called EnumNamehereToolMaterial for tools and EnumNamehereArmourMaterial for armour.
In EnumNamehereToolMaterial it would be:
package net.minecraft.src;
public enum EnumNamehereToolMaterial
{
NAMEHERE1("NAMEHERE1", 0, 0, 59, 2.0F, 0, 15),
NAMEHERE2("NAMEHERE2", 1, 1, 131, 4F, 1, 5);
private final int harvestLevel;
private final int maxUses;
private final float efficiencyOnProperMaterial;
private final int damageVsEntity;
private final int enchantability;
private EnumNamehereToolMaterial(String s, int i, int j, int k, float f, int l, int i1)
{
harvestLevel = j;
maxUses = k;
efficiencyOnProperMaterial = f;
damageVsEntity = l;
enchantability = i1;
}
public int getMaxUses()
{
return maxUses;
}
public float getEfficiencyOnProperMaterial()
{
return efficiencyOnProperMaterial;
}
public int getDamageVsEntity()
{
return damageVsEntity;
}
public int getHarvestLevel()
{
return harvestLevel;
}
public int getEnchantability()
{
return enchantability;
}
}
Where it says:
NAMEHERE1("NAMEHERE1", 0, 0, 59, 2.0F, 0, 15),
The first number is the id it needs to look something along the lines of this:
ect.
The second number is the harvest level.
The third number is the number of uses.
The fourth number is efficiency against proper materials.
The fifth number is the damage.
The last number is the enchant-ability.
EnumNamehereArmourMaterial would be:
package net.minecraft.src;
public enum EnumNamehereArmorMaterial
{
NAMEHERE1("NAMEHERE1", 0, 5, new int[] { 1, 3, 2, 1 }, 15),
NAMEHERE2("NAMEHERE2", 1, 15, new int[] { 2, 5, 4, 1 }, 12);
private int maxDamageFactor;
private int damageReductionAmountArray[];
private int enchantability;
private EnumNamehereArmorMaterial(String s, int i, int j, int ai[], int k)
{
maxDamageFactor = j;
damageReductionAmountArray = ai;
enchantability = k;
}
public int func_40576_a(int i)
{
return ItemArmor.getMaxDamageArray()[i] * maxDamageFactor;
}
public int getDamageReductionAmount(int i)
{
return damageReductionAmountArray[i];
}
public int getEnchantability()
{
return enchantability;
}
}
But alas i dont know what the numbers mean, so sorry, but iv'e tried searching it but i couldn't find out.
When you have made them work you want to go back to your mod_Namehere file and find these again:
public static final Item NameherePickaxe = new ItemPickaxe(2005, EnumToolMaterial.EMERALD).setItemName("NameherePickaxe");
public static final Item NamehereHelmet = new ItemArmor(1000, EnumArmorMaterial.DIAMOND, ModLoader.AddArmor("NamehereArmour"), 0).setItemName("NamehereHelmet");
And change them to:
public static final Item NameherePickaxe = new ItemPickaxe(2005, EnumNamehereToolMaterial.NAMEHERE1).setItemName("NameherePickaxe");
And
public static final Item NamehereHelmet = new ItemArmor(1000, EnumNamehereArmorMaterial.NAMEHERE2, ModLoader.AddArmor("NamehereArmour"), 0).setItemName("NamehereHelmet");
I found out how to make a new material, incase you wanna see click the spoiler:
How to make a new material without editing Base Classes
In the mod file there will be this for tools:
public static final Item NameherePickaxe = new ItemPickaxe(2005, EnumToolMaterial.EMERALD).setItemName("NameherePickaxe");
And this for armour:
public static final Item NamehereHelmet = new ItemArmor(1000, EnumArmorMaterial.DIAMOND, ModLoader.AddArmor("NamehereArmour"), 0).setItemName("NamehereHelmet");
or something to that effect.
All you have to do is create a new file that holds the materials and that, so make a new file called EnumNamehereToolMaterial for tools and EnumNamehereArmourMaterial for armour.
In EnumNamehereToolMaterial it would be:
package net.minecraft.src;
public enum EnumNamehereToolMaterial
{
NAMEHERE1("NAMEHERE1", 0, 0, 59, 2.0F, 0, 15),
NAMEHERE2("NAMEHERE2", 1, 1, 131, 4F, 1, 5);
private final int harvestLevel;
private final int maxUses;
private final float efficiencyOnProperMaterial;
private final int damageVsEntity;
private final int enchantability;
private EnumNamehereToolMaterial(String s, int i, int j, int k, float f, int l, int i1)
{
harvestLevel = j;
maxUses = k;
efficiencyOnProperMaterial = f;
damageVsEntity = l;
enchantability = i1;
}
public int getMaxUses()
{
return maxUses;
}
public float getEfficiencyOnProperMaterial()
{
return efficiencyOnProperMaterial;
}
public int getDamageVsEntity()
{
return damageVsEntity;
}
public int getHarvestLevel()
{
return harvestLevel;
}
public int getEnchantability()
{
return enchantability;
}
}
Where it says:
NAMEHERE1("NAMEHERE1", 0, 0, 59, 2.0F, 0, 15),
The first number is the id it needs to look something along the lines of this:
ect.
The second number is the harvest level.
The third number is the number of uses.
The fourth number is efficiency against proper materials.
The fifth number is the damage.
The last number is the enchant-ability.
EnumNamehereArmourMaterial would be:
package net.minecraft.src;
public enum EnumNamehereArmorMaterial
{
NAMEHERE1("NAMEHERE1", 0, 5, new int[] { 1, 3, 2, 1 }, 15),
NAMEHERE2("NAMEHERE2", 1, 15, new int[] { 2, 5, 4, 1 }, 12);
private int maxDamageFactor;
private int damageReductionAmountArray[];
private int enchantability;
private EnumNamehereArmorMaterial(String s, int i, int j, int ai[], int k)
{
maxDamageFactor = j;
damageReductionAmountArray = ai;
enchantability = k;
}
public int func_40576_a(int i)
{
return ItemArmor.getMaxDamageArray()[i] * maxDamageFactor;
}
public int getDamageReductionAmount(int i)
{
return damageReductionAmountArray[i];
}
public int getEnchantability()
{
return enchantability;
}
}
But alas i dont know what the numbers mean, so sorry, but iv'e tried searching it but i couldn't find out.
When you have made them work you want to go back to your mod_Namehere file and find these again:
public static final Item NameherePickaxe = new ItemPickaxe(2005, EnumToolMaterial.EMERALD).setItemName("NameherePickaxe");
public static final Item NamehereHelmet = new ItemArmor(1000, EnumArmorMaterial.DIAMOND, ModLoader.AddArmor("NamehereArmour"), 0).setItemName("NamehereHelmet");
And change them to:
public static final Item NameherePickaxe = new ItemPickaxe(2005, EnumNamehereToolMaterial.NAMEHERE1).setItemName("NameherePickaxe");
And
public static final Item NamehereHelmet = new ItemArmor(1000, EnumNamehereArmorMaterial.NAMEHERE2, ModLoader.AddArmor("NamehereArmour"), 0).setItemName("NamehereHelmet");
But change the namehere's to what you set it as.
I know how to make a new material and stuff, but I haven't had time to make a tutorial.
Okay, I posted this last page and waited a while and still have gotten no response; I have a lighting problem with some blocks I made, They emit light at 5 & 10, But for some reason are always fully lit at 15 while not lighting the sorrounding blocks that much. I had the same problem with a non-light emitting block but removing .setLightValue(XXF) fixed it but I can't do that to a block that's SUPPOSED to emit light.
Heres the code:
mod_Block.java - My only mod_ class, to clarify
/** Blocks **/
/** Ambient Stone block, emits level 5 light & blends with Dungeon Stone. **/
public static final Block Ambstone = new BlockAmbstone(160,
0).setBlockName("AmbientStone").setHardness(3F).setResistance(4F).setLightValue(10F);
/** Ambient Stone Bright block, emits level 10 light & blends with Dungeon Stone. **/
public static final Block Ambstoneb = new BlockAmbstoneb(161,
0).setBlockName("AmbientStoneBright").setHardness(3F).setResistance(4F).setLightValue(5F);
package net.minecraft.src;
import java.util.Random;
public class BlockAmbstone extends Block
{
public BlockAmbstone(int i, int j)
{
super(i, j, Material.wood);
}
public int idDropped(int i, Random random, int j)
{
return mod_Block.Ambstone.blockID;
}
public int quantityDropped(Random random)
{
return 1;
}
}
BlockAmbstoneb.java - The brighter one
package net.minecraft.src;
import java.util.Random;
public class BlockAmbstoneb extends Block
{
public BlockAmbstoneb(int i, int j)
{
super(i, j, Material.wood);
}
public int idDropped(int i, Random random, int j)
{
return mod_Block.Ambstoneb.blockID;
}
public int quantityDropped(Random random)
{
return 1;
}
}
I'm not really sure. I don't know much about the lightValue variable and how it works.
I know it's already in your to-do list, but please do a guide about a crop that has about 3 or 4 stages.
I'm trying to make it for a while now, but it doesn't work well. (right now it is a water crop)
I'll try and get the crop tutorial done this weekend. I've said it before but I might have some time this weekend.
Hey I have a problem with my mod
I get this error:
== MCP 6.0 (data: 6.0, client: 1.2.3, server: 1.2.3) ==
# found jad, jad patches, ff patches, osx patches, srgs, name csvs, doc csvs, pa
ram csvs, astyle, astyle config
== Recompiling client ==
&--#62; Cleaning bin
&--#62; Recompiling
'"C:\Program Files\Java\jdk1.7.0_03\bin\javac" -g -source 1.6 -target 1.6 -class
path "lib;lib\*;jars\...' failed : 1
== ERRORS FOUND ==
warning: [options] bootstrap class path not set in conjunction with -source 1.6
src\minecraft\net\minecraft\src\mod_Tutorials.java:5: error: &--#60;identifier&--#62; expect
ed
public static final GlowingObsidian = new GlowingObsidian(160, 37).setBlockName(
"GlowingObsidian").setHardness(50F).setResistance(2000F).setLightValue(1F);
^
1 error
1 warning
==================
!! Can not find server sources, try decompiling !!
Drücken Sie eine beliebige Taste . . .
Code:
mod_Tutorials.java:
package net.minecraft.src;
public class mod_Tutorials extends BaseMod
{
public static final GlowingObsidian = new GlowingObsidian(160, 37).setBlockName("GlowingObsidian").setHardness(50F).setResistance(2000F).setLightValue(1F);
public void load()
{
ModLoader.registerBlock(GlowingObsidian);
ModLoader.addName(GlowingObsidian, "Glowing Obsidian");
Modloader.addRecipe(new ItemStack(GlowingObsidian, 1), new Object [] {" # ", "#$#", " # ", Character.valueOf('#'), Item.yellowDust, Character.valueOf('$'), Block.Obsidian});
}
public String getVersion()
{
return "V1 1.2.3";
}
}
BlockGlowingObsidian.java:
package net.minecraft.src;
public class mod_Tutorials extends BaseMod
{
public static final GlowingObsidian = new GlowingObsidian(160, 37).setBlockName("GlowingObsidian").setHardness(50F).setResistance(2000F).setLightValue(1F);
public void load()
{
ModLoader.registerBlock(GlowingObsidian);
ModLoader.addName(GlowingObsidian, "Glowing Obsidian");
Modloader.addRecipe(new ItemStack(GlowingObsidian, 1), new Object [] {" # ", "#$#", " # ", Character.valueOf('#'), Item.yellowDust, Character.valueOf('$'), Block.Obsidian});
}
public String getVersion()
{
return "V1 1.2.3";
}
}
I hope you can help me
mfg,
CrystalStar
You need to put "Block" before you declare the name of the new instance you're creating.
public static final Block GlowingObsidian = new GlowingObsidian(160, 37).setBlockName("GlowingObsidian").setHardness(50F).setResistance(2000F).setLightValue(1F);
Ok, thanks, the thing is, since I am trying to make a boat I want it to only spawn in very watery biomes, also, it there a way to get it to only spawn on a certain level (so that my boat doesn't spawn under water) and I was also thinking that I wanted to put stairs in the design but I am thinking that I would have to include something to tell it the direction to face. Thanks
Have a look at Southclaw's reply. I would do something like that.
Good to hear! And I forgot to mention that didn't I, I did extend just Entity, I figured as it's not a moving one then I shouldn't need to use EntityLiving or any others.
The problem is I think EntityLiving handles textures in a more complete way, setting the texture variable from Entity might just not complete the process.
I'll have a look at how EntityLiving does it! And I'll add some debug prints to see if the spawning function works.
I'm not entirely sure how to bring an entity into existence in the world, at the moment I use:
Item: onItemUse
EntityMine objectID = new EntityObject(world, i, j, k);
Entity: EntityObject
public EntityMine(World world, int x, int y, int z)
{
super(world);
texture = "/mods/ModelMine_tex.png";
setSize(0.5F, 0.5F);
setLocationAndAngles(x, y, z, 0.0f, 0.0f);
setPosition(x, y, z);
posX=x;
posY=y;
posZ=z;
}
I simply copied various bits of code from entities that I know aren't living (Arrows for one, couldn't think of others apart from particle FX)
But the EntityArrow doesn't have anything about textures because I think that's handled in another area of code.
As I said before, I'm not really knowing much about basic entities. Once I know more I'll get back to you.
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
I don't suppose that you could add a more recent block of coding would be in the blocks and slabs section, to make it so they can be placed upside-down, like the vanilla steps and slabs? I created a new set of slabs and stairs... and then found out that I can't place them upside down XD
EDIT: Unless I did it all wrong. If that is the case, I apologize!
I don't suppose that you could add a more recent block of coding would be in the blocks and slabs section, to make it so they can be placed upside-down, like the vanilla steps and slabs? I created a new set of slabs and stairs... and then found out that I can't place them upside down XD
EDIT: Unless I did it all wrong. If that is the case, I apologize!
I had a quick look and I think you only need this method. Not sure but try adding it:
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
if (blockType)
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
else
{
boolean flag = (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & 8) != 0;
if (flag)
{
setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F);
}
else
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
}
}
}
Let me figure out a way to properly add that so you don't use that "blockType" variable.
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
boolean flag = (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & 8) != 0;
if (flag)
{
setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F);
}
else
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
}
}
I haven't tried either of these, but I think the second one may work.
Let me know if they don't work, and I'll try and make a tutorial on it.
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
I had a quick look and I think you only need this method. Not sure but try adding it:
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
if (blockType)
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
else
{
boolean flag = (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & 8) != 0;
if (flag)
{
setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F);
}
else
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
}
}
}
Let me figure out a way to properly add that so you don't use that "blockType" variable.
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
boolean flag = (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & 8) != 0;
if (flag)
{
setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F);
}
else
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
}
}
I haven't tried either of these, but I think the second one may work.
Let me know if they don't work, and I'll try and make a tutorial on it.
Okay, I must be doing something incorrectly. Am I replacing this whole block of code
public void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
public int getRenderType()
{
return 10;
}
with
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
boolean flag = (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & 8) != 0;
if (flag)
{
setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F);
}
else
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
}
}
EDIT: Or am I adding the contents of the one you gave me to the original? I've tried both ways, but I can't seem to get it to work. I AM new to modding, so I probably don't have the greatest understanding of what to do... that, or its because I just woke up. I'm gonna go with the latter, and hope I'm a little more clever than I think.
ANYWAYS, a brief tutorial would be superb, IF you're willing that is.
Great tutorial btw Haven't done modding in a while so this got me started. Also I would show them the switch statement when dealing with multi-texture blocks. It is a better practice then using the if-else statements.
public int getBlockTextureFromSide(int i)
{
if (i == 0)
{
return mod_Block.NamehereBottom;
}
if (i == 1)
{
return mod_Block.NamehereTop;
}
else
{
return mod_Block.NamehereSides;
}
}
}
You can easily use the switch statement in this example.
public int getBlockTextureFromSide(int i) {
switch(i) {
case 0:
return mod_Block.NamehereBottom;
case 1:
return mod_Block.NamehereTop;
default:
return mod_Block.NamehereSides;
}
}
You can also change it up like this too.
public int getBlockTextureFromSide(int i) {
switch(i) {
case 0:
case 1:
return mod_Block.Namehere;
default:
return mod_Block.NamehereSides;
}
}
When I switch statement finds a correct case it will start the code there. So lets say i = 0. It will go to case 0 and it will keep on going which ends up at case 1 also. Then it stops because of the return statement. In other switch statements you will see break statements, reason it's not in here is because of the return statement. The break statement will stop the switch statement. Look at this example, number = 10;
String test;
switch(number) {
case 5:
text = "number is 5";
// break;
case 10:
text = "number is 10";
// break;
case 15:
text = "number is 15";
// break;
case 20:
text = "number is 20";
// break;
}
When you run this, String text = "number is 20" even though the int number is 10. That's is why you need break statements, I have the in comments to see.
If I want to make a block explode when it is powered by redstone, what kind of code do I have to insert to BlockNameHere?
Have you looked at BlockTNT & EntityTNTPrimed? It is a bit different to what you want to do though, as it converts the block to an entity(EntityTNTPrimed) then that explodes.
Ok, I will try that, also: do you know how to make it spawn in just one (or maybe two) biome(s)?
Also: were would I put that code?
I'm still working on certain biome spawning for generation of blocks. I know for mobs, but still working on blocks.
I would put that code in your WorldGenNamehere class, in the generate() method. I made a few changes to his code below so that it didn't get any errors.
Okay, I must be doing something incorrectly. Am I replacing this whole block of code
public void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
public int getRenderType()
{
return 10;
}
with
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
boolean flag = (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & 8) != 0;
if (flag)
{
setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F);
}
else
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
}
}
EDIT: Or am I adding the contents of the one you gave me to the original? I've tried both ways, but I can't seem to get it to work. I AM new to modding, so I probably don't have the greatest understanding of what to do... that, or its because I just woke up. I'm gonna go with the latter, and hope I'm a little more clever than I think.
ANYWAYS, a brief tutorial would be superb, IF you're willing that is.
When I get some time, I'll make a tutorial on it. Then it's easier for everyone.
Can you make a tutorial on how to update MCP? (I don't want to lose my codes)
If you know how to do it, please make a tutorial or reply to me
Run getmodsource.bat/sh
All of your code will then be in "modsrc" in the mcp directory.
Check all of your classes are in that directory, if they aren't go and get the missing ones from src.
Copy the "modsrc" folder to another directory outside of mcp.
Run cleanup.bat/sh.
Wait until there is a new version of mcp to be downloaded. It normally takes 3 days to a week.
Run updatemcp.bat/sh
Get a jar of the new version of minecraft and install the latest ModLoader for that version.
Put it in jars/bin along with all the other jars like lwjgl, make sure you get them from your .minecraft directory because they update with the minecraft.jar.
Decompile again.
Put all the .java's from "modsrc" back into src with all of the other client/server files(depending on what your mod is)
Fix any errors you get with the new version of MCP and ModLoader.
Great tutorial btw Haven't done modding in a while so this got me started. Also I would show them the switch statement when dealing with multi-texture blocks. It is a better practice then using the if-else statements.
public int getBlockTextureFromSide(int i)
{
if (i == 0)
{
return mod_Block.NamehereBottom;
}
if (i == 1)
{
return mod_Block.NamehereTop;
}
else
{
return mod_Block.NamehereSides;
}
}
}
You can easily use the switch statement in this example.
public int getBlockTextureFromSide(int i) {
switch(i) {
case 0:
return mod_Block.NamehereBottom;
case 1:
return mod_Block.NamehereTop;
default:
return mod_Block.NamehereSides;
}
}
You can also change it up like this too.
public int getBlockTextureFromSide(int i) {
switch(i) {
case 0:
case 1:
return mod_Block.Namehere;
default:
return mod_Block.NamehereSides;
}
}
When I switch statement finds a correct case it will start the code there. So lets say i = 0. It will go to case 0 and it will keep on going which ends up at case 1 also. Then it stops because of the return statement. In other switch statements you will see break statements, reason it's not in here is because of the return statement. The break statement will stop the switch statement. Look at this example, number = 10;
String test;
switch(number) {
case 5:
text = "number is 5";
// break;
case 10:
text = "number is 10";
// break;
case 15:
text = "number is 15";
// break;
case 20:
text = "number is 20";
// break;
}
When you run this, String text = "number is 20" even though the int number is 10. That's is why you need break statements, I have the in comments to see.
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
I'm still working on certain biome spawning for generation of blocks. I know for mobs, but still working on blocks.
I would put that code in your WorldGenNamehere class, in the generate() method. I made a few changes to his code below so that it didn't get any errors.
I made a mod with this, recompiled and no errors. But when I do get errors when I'm using the startclient.bat.
Here's the crash report:
Mods loaded: 2
ModLoader 1.2.3
mod_DirtPlus 1.2.3
Minecraft has crashed!
----------------------
Minecraft has stopped running because it encountered a problem.
--- BEGIN ERROR REPORT 36b09cb1 --------
Generated 23-3-12 23:59
Minecraft: Minecraft 1.2.3
OS: Windows 7 (x86) version 6.1
Java: 1.7.0_01, Oracle Corporation
VM: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation
LWJGL: 2.4.2
OpenGL: Intel 965/963 Graphics Media Accelerator version 2.0.0 - Build 8.14.10.1930, Intel
java.lang.StringIndexOutOfBoundsException: String index out of range: 8
at java.lang.String.charAt(String.java:695)
at net.minecraft.src.CraftingManager.addRecipe(CraftingManager.java:382)
at net.minecraft.src.ModLoader.addRecipe(ModLoader.java:409)
at net.minecraft.src.mod_DirtPlus.load(mod_DirtPlus.java:23)
at net.minecraft.src.ModLoader.init(ModLoader.java:853)
at net.minecraft.src.ModLoader.addAllRenderers(ModLoader.java:154)
at net.minecraft.src.RenderManager.<init>(RenderManager.java:85)
at net.minecraft.src.RenderManager.<clinit>(RenderManager.java:12)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:423)
at net.minecraft.client.Minecraft.run(Minecraft.java:784)
at java.lang.Thread.run(Thread.java:722)
--- END ERROR REPORT 4f739c97 ----------
Post your code please. But from this, I can see that there is an error with your recipe.
What kind of tutorial? The code remains the same over each OS. The beauty of Java.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
I mean I don't know which one to download when I try and get Java Development Pack. I have no idea which one to get T_T
I tried the last one, but it was just a bunch of folders and stuff. Isn't it supposed to be an application?
I'm not sure about Macs. I do know that Java comes with the OS already, but not sure about the JDK.
Go to Terminal, and type
javac -version
If that returns with actual information and not "cannot find command" or whatever, then the JDK is already installed. If you're not sure, post what it returns.
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
I'm not sue about Macs. I do know that Java comes with the OS already, but not sure about the JDK.
Go to Terminal, and type
javac -version
If that returns with actual information and not "cannot find command" or whatever, then the JDK is already installed. If you're not sure, post what it returns.
It says "javac 1.6.0_29"
EDIT: I searched "Java" in my search bar. Got something called "Java VisualVM". Is that right?
Heres the code:
mod_Block.java - My only mod_ class, to clarify
/** Blocks **/ /** Ambient Stone block, emits level 5 light & blends with Dungeon Stone. **/ public static final Block Ambstone = new BlockAmbstone(160, 0).setBlockName("AmbientStone").setHardness(3F).setResistance(4F).setLightValue(10F); /** Ambient Stone Bright block, emits level 10 light & blends with Dungeon Stone. **/ public static final Block Ambstoneb = new BlockAmbstoneb(161, 0).setBlockName("AmbientStoneBright").setHardness(3F).setResistance(4F).setLightValue(5F);and in public void load():
Ambstone.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/modZombie_gfx/ambstone1.png"); ModLoader.registerBlock(Ambstone); ModLoader.addName(Ambstone, "Ambient Stone"); ModLoader.addRecipe(new ItemStack(Ambstone, 1), new Object [] {" @ ", "@#@", " @ ", Character.valueOf('@'), Block.torchWood, Character.valueOf('#'), Dstone}); Ambstoneb.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/modZombie_gfx/ambstone2.png"); ModLoader.registerBlock(Ambstoneb); ModLoader.addName(Ambstoneb, "Ambient Stone Bright"); ModLoader.addRecipe(new ItemStack(Ambstoneb, 1), new Object [] {" @ ", " # ", " @ ", Character.valueOf('@'), Block.torchWood, Character.valueOf('#'), Ambstone});BlockAmbstone.java - The dimmer block
package net.minecraft.src; import java.util.Random; public class BlockAmbstone extends Block { public BlockAmbstone(int i, int j) { super(i, j, Material.wood); } public int idDropped(int i, Random random, int j) { return mod_Block.Ambstone.blockID; } public int quantityDropped(Random random) { return 1; } }BlockAmbstoneb.java - The brighter one
package net.minecraft.src; import java.util.Random; public class BlockAmbstoneb extends Block { public BlockAmbstoneb(int i, int j) { super(i, j, Material.wood); } public int idDropped(int i, Random random, int j) { return mod_Block.Ambstoneb.blockID; } public int quantityDropped(Random random) { return 1; } }How does this help me? I checked the code, It says 0.0-1.0F can translate to 1F to 15F. The lighting is correct, 15F is lowest, 1F is highest - the blocks are set accordingly.Converts internally to 0-15F, this means ingame,
I know how to fix this - Thanks.Actually, no, I don't - the code says that it finds the light value by taking 15 and multiplying it by the variable you put in, So if you put in 0.2 you get 3 - This also means the value of 5 would be 0.33333333 - etc, Isn't there another way to do this?
Another question; when the game updates, How do I know what to change in my mod in order to fix it should I need to?
I found out how to make a new material, incase you wanna see click the spoiler:
In the mod file there will be this for tools:
public static final Item NameherePickaxe = new ItemPickaxe(2005, EnumToolMaterial.EMERALD).setItemName("NameherePickaxe");And this for armour:
public static final Item NamehereHelmet = new ItemArmor(1000, EnumArmorMaterial.DIAMOND, ModLoader.AddArmor("NamehereArmour"), 0).setItemName("NamehereHelmet");or something to that effect.
All you have to do is create a new file that holds the materials and that, so make a new file called EnumNamehereToolMaterial for tools and EnumNamehereArmourMaterial for armour.
In EnumNamehereToolMaterial it would be:
package net.minecraft.src; public enum EnumNamehereToolMaterial { NAMEHERE1("NAMEHERE1", 0, 0, 59, 2.0F, 0, 15), NAMEHERE2("NAMEHERE2", 1, 1, 131, 4F, 1, 5); private final int harvestLevel; private final int maxUses; private final float efficiencyOnProperMaterial; private final int damageVsEntity; private final int enchantability; private EnumNamehereToolMaterial(String s, int i, int j, int k, float f, int l, int i1) { harvestLevel = j; maxUses = k; efficiencyOnProperMaterial = f; damageVsEntity = l; enchantability = i1; } public int getMaxUses() { return maxUses; } public float getEfficiencyOnProperMaterial() { return efficiencyOnProperMaterial; } public int getDamageVsEntity() { return damageVsEntity; } public int getHarvestLevel() { return harvestLevel; } public int getEnchantability() { return enchantability; } }Where it says:
NAMEHERE1("NAMEHERE1", 0, 0, 59, 2.0F, 0, 15),The first number is the id it needs to look something along the lines of this:
NAMEHERE1("NAMEHERE1", 0, 0, 59, 2.0F, 0, 15), NAMEHERE2("NAMEHERE2", 1, 1, 59, 2.0F, 0, 15), NAMEHERE3("NAMEHERE3", 2, 2, 59, 2.0F, 0, 15);ect.
The second number is the harvest level.
The third number is the number of uses.
The fourth number is efficiency against proper materials.
The fifth number is the damage.
The last number is the enchant-ability.
EnumNamehereArmourMaterial would be:
package net.minecraft.src; public enum EnumNamehereArmorMaterial { NAMEHERE1("NAMEHERE1", 0, 5, new int[] { 1, 3, 2, 1 }, 15), NAMEHERE2("NAMEHERE2", 1, 15, new int[] { 2, 5, 4, 1 }, 12); private int maxDamageFactor; private int damageReductionAmountArray[]; private int enchantability; private EnumNamehereArmorMaterial(String s, int i, int j, int ai[], int k) { maxDamageFactor = j; damageReductionAmountArray = ai; enchantability = k; } public int func_40576_a(int i) { return ItemArmor.getMaxDamageArray()[i] * maxDamageFactor; } public int getDamageReductionAmount(int i) { return damageReductionAmountArray[i]; } public int getEnchantability() { return enchantability; } }But alas i dont know what the numbers mean, so sorry, but iv'e tried searching it but i couldn't find out.
When you have made them work you want to go back to your mod_Namehere file and find these again:
public static final Item NameherePickaxe = new ItemPickaxe(2005, EnumToolMaterial.EMERALD).setItemName("NameherePickaxe");public static final Item NamehereHelmet = new ItemArmor(1000, EnumArmorMaterial.DIAMOND, ModLoader.AddArmor("NamehereArmour"), 0).setItemName("NamehereHelmet");And change them to:
public static final Item NameherePickaxe = new ItemPickaxe(2005, EnumNamehereToolMaterial.NAMEHERE1).setItemName("NameherePickaxe");And
public static final Item NamehereHelmet = new ItemArmor(1000, EnumNamehereArmorMaterial.NAMEHERE2, ModLoader.AddArmor("NamehereArmour"), 0).setItemName("NamehereHelmet");But change the namehere's to what you set it as.
I know how to make a new material and stuff, but I haven't had time to make a tutorial.
The game uses 128 for it spawning of things. But whenever I try that, all my stuff goes up to 128. Maybe an issue with ModLoader since Anvil?
I'm still trying to figure that out myself.
I'm not really sure. I don't know much about the lightValue variable and how it works.
I'll try and get the crop tutorial done this weekend. I've said it before but I might have some time this weekend.
You need to put "Block" before you declare the name of the new instance you're creating.
public static final Block GlowingObsidian = new GlowingObsidian(160, 37).setBlockName("GlowingObsidian").setHardness(50F).setResistance(2000F).setLightValue(1F);Have a look at Southclaw's reply. I would do something like that.
As I said before, I'm not really knowing much about basic entities. Once I know more I'll get back to you.
together they are powerful beyond imagination."
EDIT: Unless I did it all wrong. If that is the case, I apologize!
I had a quick look and I think you only need this method. Not sure but try adding it:
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { if (blockType) { setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } else { boolean flag = (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & 8) != 0; if (flag) { setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F); } else { setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } } }Let me figure out a way to properly add that so you don't use that "blockType" variable.
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { boolean flag = (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & 8) != 0; if (flag) { setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F); } else { setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } }I haven't tried either of these, but I think the second one may work.
Let me know if they don't work, and I'll try and make a tutorial on it.
together they are powerful beyond imagination."
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumOk, I will try that, also: do you know how to make it spawn in just one (or maybe two) biome(s)?
Also: were would I put that code?
Okay, I must be doing something incorrectly. Am I replacing this whole block of code
public void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k) { setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } public int getRenderType() { return 10; }with
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { boolean flag = (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & 8) != 0; if (flag) { setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F); } else { setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } }EDIT: Or am I adding the contents of the one you gave me to the original? I've tried both ways, but I can't seem to get it to work. I AM new to modding, so I probably don't have the greatest understanding of what to do... that, or its because I just woke up. I'm gonna go with the latter, and hope I'm a little more clever than I think.
ANYWAYS, a brief tutorial would be superb, IF you're willing that is.
If you know how to do it, please make a tutorial or reply to me
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html
public int getBlockTextureFromSide(int i) { if (i == 0) { return mod_Block.NamehereBottom; } if (i == 1) { return mod_Block.NamehereTop; } else { return mod_Block.NamehereSides; } } }You can easily use the switch statement in this example.
public int getBlockTextureFromSide(int i) { switch(i) { case 0: return mod_Block.NamehereBottom; case 1: return mod_Block.NamehereTop; default: return mod_Block.NamehereSides; } }You can also change it up like this too.
public int getBlockTextureFromSide(int i) { switch(i) { case 0: case 1: return mod_Block.Namehere; default: return mod_Block.NamehereSides; } }When I switch statement finds a correct case it will start the code there. So lets say i = 0. It will go to case 0 and it will keep on going which ends up at case 1 also. Then it stops because of the return statement. In other switch statements you will see break statements, reason it's not in here is because of the return statement. The break statement will stop the switch statement. Look at this example, number = 10;
String test; switch(number) { case 5: text = "number is 5"; // break; case 10: text = "number is 10"; // break; case 15: text = "number is 15"; // break; case 20: text = "number is 20"; // break; }When you run this, String text = "number is 20" even though the int number is 10. That's is why you need break statements, I have the in comments to see.
Of course
Have you looked at BlockTNT & EntityTNTPrimed? It is a bit different to what you want to do though, as it converts the block to an entity(EntityTNTPrimed) then that explodes.
I'm still working on certain biome spawning for generation of blocks. I know for mobs, but still working on blocks.
I would put that code in your WorldGenNamehere class, in the generate() method. I made a few changes to his code below so that it didn't get any errors.
if(world.getBlockId(i, j, k) != Block.waterStill.blockID && world.getBlockId(i, j + 1, k) != 0) { return false; }So it would fit like this:
public boolean generate(World world, Random rand, int i, int j, int k) { if(world.getBlockId(i, j, k) != Block.waterStill.blockID && world.getBlockId(i, j + 1, k) != 0) { return false; } int block = Block.planks.blockID; world.setBlockWithNotify(i, j + 1, k, block); //rest of world.setBlockWithNotify's, etc. here. return true; }When I get some time, I'll make a tutorial on it. Then it's easier for everyone.
Thanks
together they are powerful beyond imagination."
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumUm, it didn't seem to work, no errors, but it will still spawn below the water.
my code:
package net.minecraft.src; import java.util.Random; public class WorldGenBoat extends WorldGenerator { public WorldGenBoat() { } public boolean generate(World world, Random random, int i, int j, int k) { if(world.getBlockId(i, j, k) != Block.waterStill.blockID && world.getBlockId(i, j + 1, k) != 0) { return false; } int wood = Block.planks.blockID; world.setBlockWithNotify(i, j, k, wood); world.setBlockWithNotify(i, j, k +1, wood); world.setBlockWithNotify(i, j, k +2, wood); world.setBlockWithNotify(i, j, k +3, wood); world.setBlockWithNotify(i, j, k +4, wood); world.setBlockWithNotify(i, j, k +5, wood); world.setBlockWithNotify(i, j, k +6, wood); world.setBlockWithNotify(i, j, k +7, wood); return true; } }Post your code please. But from this, I can see that there is an error with your recipe.
I'll have a test and get back to you.
What kind of tutorial? The code remains the same over each OS. The beauty of Java.
together they are powerful beyond imagination."
I tried the last one, but it was just a bunch of folders and stuff. Isn't it supposed to be an application?
I'm not sure about Macs. I do know that Java comes with the OS already, but not sure about the JDK.
Go to Terminal, and type
If that returns with actual information and not "cannot find command" or whatever, then the JDK is already installed. If you're not sure, post what it returns.
together they are powerful beyond imagination."
It says "javac 1.6.0_29"
EDIT: I searched "Java" in my search bar. Got something called "Java VisualVM". Is that right?