The Meaning of Life, the Universe, and Everything.
Location:
Sydney
Join Date:
8/26/2012
Posts:
50
Minecraft:
tehherb
Xbox:
Viol3ntHerb
Member Details
Hey I just tried to follow the crop tutorial however I can't actually plant the seeds in tilled dirt. the items are all in game and I can place the final item on dirt, but not grow it.
Block
package net.minecraft.src;
import java.util.Random;
public class BlockOpiumBlock extends BlockFlower
{
public BlockOpiumBlock(int i, int j)
{
super(i, j);
blockIndexInTexture = j;
setTickRandomly(true);
float f = 0.5F;
setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);
}
/**
* Gets passed in the blockID of the block below and supposed to return true if its allowed to grow on the type of
* blockID passed in. Args: blockID.
* This basically checks to see if the block below is a tilled field/tilled dirt. If it is true then the crop can grow.
*/
protected boolean canThisPlantGrowOnThisBlockID(int par1)
{
return par1 == Block.tilledField.blockID;
}
/**
* Ticks the block if it's been scheduled. This method gets scheduled to run because of the setTickRandomly part in the constructor of the class.
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
super.updateTick(par1World, par2, par3, par4, par5Random);
if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9)
{
int i = par1World.getBlockMetadata(par2, par3, par4);
if (i < 3)
{
float f = getGrowthRate(par1World, par2, par3, par4);
if (par5Random.nextInt((int)(25F / f) + 1) == 0)
{
i++;
par1World.setBlockMetadataWithNotify(par2, par3, par4, i);
}
}
}
}
/**
* This method allows you to use bonemeal on your crop. Code explanation below:
ItemStack itemstack = entityplayer.inventory.getCurrentItem(); - This line makes "itemstack" equal to the item currently in the players hand.
if(itemstack != null && itemstack.itemID == Item.dyePowder.shiftedIndex) - This line checks if the item in players hand is equal to dye.
if(itemstack.getItemDamage() == 15) - This line checks if the damage value of that item is 15. Item.dyePowder's damage value of 15 is bonemeal.
world.setBlockMetadataWithNotify(i, j, k, 8); - This line sets the metadata value of the block to 8 which is the final growth stage.
itemstack.stackSize--; - This line makes the stack size go down by one.
world.notifyBlockChange(i, j, k, 0); - This line notifys adjacent blocks that this block has updated its state.
*/
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
{
ItemStack itemstack = par5EntityPlayer.inventory.getCurrentItem();
if(itemstack != null && itemstack.itemID == Item.dyePowder.shiftedIndex)
{
if(itemstack.getItemDamage() == 15)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 8);
itemstack.stackSize--;
par1World.notifyBlockChange(par2, par3, par4, 0);
}
}
super.onBlockActivated(par1World, par2, par3, par4, par5EntityPlayer, par6, par7, par8, par9);
return true;
}
/**
* Gets the growth rate for the crop. Setup to encourage rows by halving growth rate if there is diagonals, crops on
* different sides that aren't opposing, and by adding growth for every crop next to this one (and for crop below
* this one). Args: x, y, z
*/
private float getGrowthRate(World par1World, int par2, int par3, int par4)
{
float f = 1.0F;
int i = par1World.getBlockId(par2, par3, par4 - 1);
int j = par1World.getBlockId(par2, par3, par4 + 1);
int k = par1World.getBlockId(par2 - 1, par3, par4);
int l = par1World.getBlockId(par2 + 1, par3, par4);
int i1 = par1World.getBlockId(par2 - 1, par3, par4 - 1);
int j1 = par1World.getBlockId(par2 + 1, par3, par4 - 1);
int k1 = par1World.getBlockId(par2 + 1, par3, par4 + 1);
int l1 = par1World.getBlockId(par2 - 1, par3, par4 + 1);
boolean flag = k == blockID || l == blockID;
boolean flag1 = i == blockID || j == blockID;
boolean flag2 = i1 == blockID || j1 == blockID || k1 == blockID || l1 == blockID;
for (int i2 = par2 - 1; i2 <= par2 + 1; i2++)
{
for (int j2 = par4 - 1; j2 <= par4 + 1; j2++)
{
int k2 = par1World.getBlockId(i2, par3 - 1, j2);
float f1 = 0.0F;
if (k2 == Block.tilledField.blockID)
{
f1 = 1.0F;
if (par1World.getBlockMetadata(i2, par3 - 1, j2) > 0)
{
f1 = 3F;
}
}
if (i2 != par2 || j2 != par4)
{
f1 /= 4F;
}
f += f1;
}
}
if (flag2 || flag && flag1)
{
f /= 2.0F;
}
return f;
}
/**
* The type of render function that is called for this block. The render type of 6 gets the texture and places it four times around the sides of the block and leaves nothing on the top or bottom.
*/
public int getRenderType()
{
return 6;
}
/**
* Drops the block items with a specified chance of dropping the specified items
*/
public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
{
super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, 0);
if (par1World.isRemote)
{
return;
}
int i = 3 + par7;
for (int j = 0; j < i; j++)
{
if (par1World.rand.nextInt(15) <= par5)
{
float f = 0.7F;
float f1 = par1World.rand.nextFloat() * f + (1.0F - f) * 0.5F;
float f2 = par1World.rand.nextFloat() * f + (1.0F - f) * 0.5F;
float f3 = par1World.rand.nextFloat() * f + (1.0F - f) * 0.5F;
EntityItem entityitem = new EntityItem(par1World, (float)par2 + f1, (float)par3 + f2, (float)par4 + f3, new ItemStack(mod_MUI.opiumseeds));
entityitem.delayBeforeCanPickup = 10;
par1World.spawnEntityInWorld(entityitem);
}
}
}
/**
* Returns the ID of the items to drop on destruction. "i" is equal to the blocks metadata value(explained slightly more in the getBlockTextureFromSideAndMetadata method below). This means that it will check that that value is equal to 8(the final stage of growth) and if it is then it will drop wheat. It may be fairly obvious, but the 'else' statement means that if the growth state is not equal to 7 then drop nothing (-1 means nothing)
*/
public int idDropped(int i, Random random, int j)
{
if (i == 8)
{
return Item.wheat.shiftedIndex;
}
else
{
return -1;
}
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return 1;
}
/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata.
* As you may have been able to tell from the line above, "j" is equal to the metadata value of the block. This checks if that value is equal to a certain number then sets the blocks texture to what you have defined.
* The things that are being returned are the ints in your mod_ class which you created and set to your texture for the specific stages of growth.
*/
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
if(j == 0)
{
return blockIndexInTexture;
}
if(j == 1)
{
return mod_MUI.opiumstageone;
}
if(j == 2)
{
return mod_MUI.opiumstagetwo;
}
if(j == 3)
{
return mod_MUI.opiumstagethree;
}
return j;
}
}
Seeds
package net.minecraft.src;
public class ItemOpiumSeeds extends Item
{
/** The type of block this seed turns into (wheat or pumpkin stems for instance)*/
private int blockType;
/** BlockID of the block the seeds can be planted on. */
private int soilBlockID;
public ItemOpiumSeeds(int i, int j, int k)
{
super(i);
blockType = j;
soilBlockID = k;
}
/**
* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
* True if something happen and false if it don't. This is for ITEMS, not BLOCKS !
*/
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7)
{
if (par7 != 1)
{
return false;
}
if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6) || !par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6))
{
return false;
}
int i = par3World.getBlockId(par4, par5, par6);
if (i == soilBlockID && par3World.isAirBlock(par4, par5 + 1, par6))
{
par3World.setBlockWithNotify(par4, par5 + 1, par6, blockType);
par1ItemStack.stackSize--;
return true;
}
else
{
return false;
}
}
}
Hey I just tried to follow the crop tutorial however I can't actually plant the seeds in tilled dirt. the items are all in game and I can place the final item on dirt, but not grow it.
Block
package net.minecraft.src;
import java.util.Random;
public class BlockOpiumBlock extends BlockFlower
{
public BlockOpiumBlock(int i, int j)
{
super(i, j);
blockIndexInTexture = j;
setTickRandomly(true);
float f = 0.5F;
setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);
}
/**
* Gets passed in the blockID of the block below and supposed to return true if its allowed to grow on the type of
* blockID passed in. Args: blockID.
* This basically checks to see if the block below is a tilled field/tilled dirt. If it is true then the crop can grow.
*/
protected boolean canThisPlantGrowOnThisBlockID(int par1)
{
return par1 == Block.tilledField.blockID;
}
/**
* Ticks the block if it's been scheduled. This method gets scheduled to run because of the setTickRandomly part in the constructor of the class.
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
super.updateTick(par1World, par2, par3, par4, par5Random);
if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9)
{
int i = par1World.getBlockMetadata(par2, par3, par4);
if (i < 3)
{
float f = getGrowthRate(par1World, par2, par3, par4);
if (par5Random.nextInt((int)(25F / f) + 1) == 0)
{
i++;
par1World.setBlockMetadataWithNotify(par2, par3, par4, i);
}
}
}
}
/**
* This method allows you to use bonemeal on your crop. Code explanation below:
ItemStack itemstack = entityplayer.inventory.getCurrentItem(); - This line makes "itemstack" equal to the item currently in the players hand.
if(itemstack != null && itemstack.itemID == Item.dyePowder.shiftedIndex) - This line checks if the item in players hand is equal to dye.
if(itemstack.getItemDamage() == 15) - This line checks if the damage value of that item is 15. Item.dyePowder's damage value of 15 is bonemeal.
world.setBlockMetadataWithNotify(i, j, k, 8); - This line sets the metadata value of the block to 8 which is the final growth stage.
itemstack.stackSize--; - This line makes the stack size go down by one.
world.notifyBlockChange(i, j, k, 0); - This line notifys adjacent blocks that this block has updated its state.
*/
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
{
ItemStack itemstack = par5EntityPlayer.inventory.getCurrentItem();
if(itemstack != null && itemstack.itemID == Item.dyePowder.shiftedIndex)
{
if(itemstack.getItemDamage() == 15)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 8);
itemstack.stackSize--;
par1World.notifyBlockChange(par2, par3, par4, 0);
}
}
super.onBlockActivated(par1World, par2, par3, par4, par5EntityPlayer, par6, par7, par8, par9);
return true;
}
/**
* Gets the growth rate for the crop. Setup to encourage rows by halving growth rate if there is diagonals, crops on
* different sides that aren't opposing, and by adding growth for every crop next to this one (and for crop below
* this one). Args: x, y, z
*/
private float getGrowthRate(World par1World, int par2, int par3, int par4)
{
float f = 1.0F;
int i = par1World.getBlockId(par2, par3, par4 - 1);
int j = par1World.getBlockId(par2, par3, par4 + 1);
int k = par1World.getBlockId(par2 - 1, par3, par4);
int l = par1World.getBlockId(par2 + 1, par3, par4);
int i1 = par1World.getBlockId(par2 - 1, par3, par4 - 1);
int j1 = par1World.getBlockId(par2 + 1, par3, par4 - 1);
int k1 = par1World.getBlockId(par2 + 1, par3, par4 + 1);
int l1 = par1World.getBlockId(par2 - 1, par3, par4 + 1);
boolean flag = k == blockID || l == blockID;
boolean flag1 = i == blockID || j == blockID;
boolean flag2 = i1 == blockID || j1 == blockID || k1 == blockID || l1 == blockID;
for (int i2 = par2 - 1; i2 <= par2 + 1; i2++)
{
for (int j2 = par4 - 1; j2 <= par4 + 1; j2++)
{
int k2 = par1World.getBlockId(i2, par3 - 1, j2);
float f1 = 0.0F;
if (k2 == Block.tilledField.blockID)
{
f1 = 1.0F;
if (par1World.getBlockMetadata(i2, par3 - 1, j2) > 0)
{
f1 = 3F;
}
}
if (i2 != par2 || j2 != par4)
{
f1 /= 4F;
}
f += f1;
}
}
if (flag2 || flag && flag1)
{
f /= 2.0F;
}
return f;
}
/**
* The type of render function that is called for this block. The render type of 6 gets the texture and places it four times around the sides of the block and leaves nothing on the top or bottom.
*/
public int getRenderType()
{
return 6;
}
/**
* Drops the block items with a specified chance of dropping the specified items
*/
public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
{
super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, 0);
if (par1World.isRemote)
{
return;
}
int i = 3 + par7;
for (int j = 0; j < i; j++)
{
if (par1World.rand.nextInt(15) <= par5)
{
float f = 0.7F;
float f1 = par1World.rand.nextFloat() * f + (1.0F - f) * 0.5F;
float f2 = par1World.rand.nextFloat() * f + (1.0F - f) * 0.5F;
float f3 = par1World.rand.nextFloat() * f + (1.0F - f) * 0.5F;
EntityItem entityitem = new EntityItem(par1World, (float)par2 + f1, (float)par3 + f2, (float)par4 + f3, new ItemStack(mod_MUI.opiumseeds));
entityitem.delayBeforeCanPickup = 10;
par1World.spawnEntityInWorld(entityitem);
}
}
}
/**
* Returns the ID of the items to drop on destruction. "i" is equal to the blocks metadata value(explained slightly more in the getBlockTextureFromSideAndMetadata method below). This means that it will check that that value is equal to 8(the final stage of growth) and if it is then it will drop wheat. It may be fairly obvious, but the 'else' statement means that if the growth state is not equal to 7 then drop nothing (-1 means nothing)
*/
public int idDropped(int i, Random random, int j)
{
if (i == 8)
{
return Item.wheat.shiftedIndex;
}
else
{
return -1;
}
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return 1;
}
/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata.
* As you may have been able to tell from the line above, "j" is equal to the metadata value of the block. This checks if that value is equal to a certain number then sets the blocks texture to what you have defined.
* The things that are being returned are the ints in your mod_ class which you created and set to your texture for the specific stages of growth.
*/
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
if(j == 0)
{
return blockIndexInTexture;
}
if(j == 1)
{
return mod_MUI.opiumstageone;
}
if(j == 2)
{
return mod_MUI.opiumstagetwo;
}
if(j == 3)
{
return mod_MUI.opiumstagethree;
}
return j;
}
}
Seeds
package net.minecraft.src;
public class ItemOpiumSeeds extends Item
{
/** The type of block this seed turns into (wheat or pumpkin stems for instance)*/
private int blockType;
/** BlockID of the block the seeds can be planted on. */
private int soilBlockID;
public ItemOpiumSeeds(int i, int j, int k)
{
super(i);
blockType = j;
soilBlockID = k;
}
/**
* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
* True if something happen and false if it don't. This is for ITEMS, not BLOCKS !
*/
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7)
{
if (par7 != 1)
{
return false;
}
if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6) || !par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6))
{
return false;
}
int i = par3World.getBlockId(par4, par5, par6);
if (i == soilBlockID && par3World.isAirBlock(par4, par5 + 1, par6))
{
par3World.setBlockWithNotify(par4, par5 + 1, par6, blockType);
par1ItemStack.stackSize--;
return true;
}
else
{
return false;
}
}
}
Post your mod_ code.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
Does anyone know which class the furnace fuels are located? (I'm not referring to FurnaceRecipes)
TileEntityFurnace.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
Trying not to sound like a newb here, but since many mob tutorials are outdated, I was wondering if you could tell what was the method to adding a mob name. Unlike entity.Werewolf. Here is some of my mod_Class, if that helps.
public class mod_WereWolf extends BaseMod{
private Set trackedEntities = new HashSet();
public Timer timer;
public WorldProvider provider;
public World world;
public static boolean isInfected;
public static final Block silverOre = new Block(200, 0, Material.iron).setHardness(3.0F).setResistance(5.0F).setCreativeTab(CreativeTabs.tabBlock).setBlockName("oreSilver");
public static final Item ringNight = new Item(2200).setTabToDisplayOn(CreativeTabs.tabTools).setItemName("ringNight");
public KeyBinding key_test = new KeyBinding("keyTest", Keyboard.KEY_U);
public static boolean iswolf;
public void keyboardEvent(KeyBinding keybinding)
{
if(keybinding == this.key_test)
{
iswolf = !iswolf;
}
}
@Override
public void load() {
//Textures
ringNight.iconIndex = ModLoader.addOverride("/gui/items.png", "/WW/Ring.png");
silverOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/WW/Ore.png");
ModLoader.registerBlock(silverOre);
//names
ModLoader.addName(silverOre, "Silver Ore");
ModLoader.addName(ringNight, "Ring of Night");
ModLoader.registerEntityID(EntityWerewolf.class, "Werewolf", -128);
ModLoader.addSpawn(EntityWerewolf.class, 2, 1, 3, EnumCreatureType.monster);
ModLoader.setInGameHook(this, true, false);
ModLoader.registerKey(this, this.key_test, false);
}
The Meaning of Life, the Universe, and Everything.
Location:
Madison
Join Date:
12/4/2010
Posts:
198
Minecraft:
jrockjake
Member Details
Getting an error for my mod:
package net.minecraft.src;
public class mod_VolcanicItems extends BaseMod{
public static final Block volcBlock = new BlockVolcanite(160, 0).setBlockName("vblock").setHardness(2F).setResistance(6F).setStepSound(Block.soundStoneFootstep).setCreativeTab(CreativeTabs.tabBlock);
public static final Item vshard = new ItemVolcanicShard(5000).setItemName("vshard");
public static final Block vglassBlock = new BlockVolcanicGlass(161, 0).setBlockName("vglass").setHardness(1F).setResistance(3F).setCreativeTab(CreativeTabs.tabDeco);
public void load() {
volcBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/gtf/volcanoblock.png");
vshard.iconIndex = ModLoader.addOverride("/gui/items.png", "/gtf/volcanicshard.png");
ModLoader.registerBlock(volcBlock);
ModLoader.addName(volcBlock, "Volcanite");
ModLoader.addName(vshard, "Volcanic Shard");
ModLoader.addRecipe(new ItemStack(volcBlock, 1), new Object [] {"###", "###", "###", Character.valueOf('#'), vshard.shiftedIndex});
}
public String getVersion() {
return "For Minecraft 1.3.2 for Ocelot-kun";
}
}
Trying not to sound like a newb here, but since many mob tutorials are outdated, I was wondering if you could tell what was the method to adding a mob name. Unlike entity.Werewolf. Here is some of my mod_Class, if that helps.
public class mod_WereWolf extends BaseMod{
private Set trackedEntities = new HashSet();
public Timer timer;
public WorldProvider provider;
public World world;
public static boolean isInfected;
public static final Block silverOre = new Block(200, 0, Material.iron).setHardness(3.0F).setResistance(5.0F).setCreativeTab(CreativeTabs.tabBlock).setBlockName("oreSilver");
public static final Item ringNight = new Item(2200).setTabToDisplayOn(CreativeTabs.tabTools).setItemName("ringNight");
public KeyBinding key_test = new KeyBinding("keyTest", Keyboard.KEY_U);
public static boolean iswolf;
public void keyboardEvent(KeyBinding keybinding)
{
if(keybinding == this.key_test)
{
iswolf = !iswolf;
}
}
@Override
public void load() {
//Textures
ringNight.iconIndex = ModLoader.addOverride("/gui/items.png", "/WW/Ring.png");
silverOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/WW/Ore.png");
ModLoader.registerBlock(silverOre);
//names
ModLoader.addName(silverOre, "Silver Ore");
ModLoader.addName(ringNight, "Ring of Night");
ModLoader.registerEntityID(EntityWerewolf.class, "Werewolf", -128);
ModLoader.addSpawn(EntityWerewolf.class, 2, 1, 3, EnumCreatureType.monster);
ModLoader.setInGameHook(this, true, false);
ModLoader.registerKey(this, this.key_test, false);
}
package net.minecraft.src;
public class mod_VolcanicItems extends BaseMod{
public static final Block volcBlock = new BlockVolcanite(160, 0).setBlockName("vblock").setHardness(2F).setResistance(6F).setStepSound(Block.soundStoneFootstep).setCreativeTab(CreativeTabs.tabBlock);
public static final Item vshard = new ItemVolcanicShard(5000).setItemName("vshard");
public static final Block vglassBlock = new BlockVolcanicGlass(161, 0).setBlockName("vglass").setHardness(1F).setResistance(3F).setCreativeTab(CreativeTabs.tabDeco);
public void load() {
volcBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/gtf/volcanoblock.png");
vshard.iconIndex = ModLoader.addOverride("/gui/items.png", "/gtf/volcanicshard.png");
ModLoader.registerBlock(volcBlock);
ModLoader.addName(volcBlock, "Volcanite");
ModLoader.addName(vshard, "Volcanic Shard");
ModLoader.addRecipe(new ItemStack(volcBlock, 1), new Object [] {"###", "###", "###", Character.valueOf('#'), vshard.shiftedIndex});
}
public String getVersion() {
return "For Minecraft 1.3.2 for Ocelot-kun";
}
}
No error = no help.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
When I get around to it. Probably in a few weeks. Working on fixing some of these up first.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
Thanks it works! However there is still one issue, with the same code as previously posted the plants don't actually grow. If I place seeds in tilled dirt then they instantly end up at the 3rd form and can be harvested. How can I fix this?
Add .setStepSound(Block.soundGrassFootstep) to the public static final line of the block. You can change the sound to any sound in Block.
Diamond is 1.
Thanks it works! However there is still one issue, with the same code as previously posted the plants don't actually grow. If I place seeds in tilled dirt then they instantly end up at the 3rd form and can be harvested. How can I fix this?
I can't seem to reproduce the error at the moment. I'll try again tomorrow, remind me if I forget and don't reply.
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
Is there a way to add a new damageSource without editing the base class DamageSource?
Edit: never mind, I can just use the cactus one. But it won't damage me when I step on it. Here is the code that should make it damage any mob that steps on it:
public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity)
{
entity.attackEntityFrom(DamageSource.cactus, 1);
}
i am having a problem with adding a crop. i did a mash-up of the crop code in 1.3.1 and the tutorial code for the BlockCorn file. For the ItemCornSeeds file i just copied the ItemSeeds file in 1.3.1 and I followed this tutorial for the mod_ file. i had to put mod_everythingMinecraft.corn.blockID in the corn seeds public static line instead of in the tut where it said just to do corn.blockID (when i did that, i got an error) when i run MC with no errors in my code, MC crashes with a null pointer exception
here is my error:
Minecraft has crashed!
----------------------
Minecraft has stopped running because it encountered a problem; Exception occured in ModLoader
This error has been saved to C:\MCP's\MCP 1.3.1\jars\.\crash-reports\crash-2012-08-29_18.23.40-client.txt for your convenience. Please include a copy of this file if you report this crash to anyone.
--- BEGIN ERROR REPORT b2dc922d --------
Generated 8/29/12 6:23 PM
- Minecraft Version: 1.3.1
- Operating System: Windows 7 (amd64) version 6.1
- Java Version: 1.7.0_03, Oracle Corporation
- Java VM Version: Java HotSpot™ 64-Bit Server VM (mixed mode), Oracle Corporation
- Memory: 997418648 bytes (951 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB)
- JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
- ModLoader: Mods loaded: 1
ModLoader 1.3.1
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:353)
at net.minecraft.src.ModLoader.readFromClassPath(ModLoader.java:1344)
at net.minecraft.src.ModLoader.init(ModLoader.java:919)
at net.minecraft.src.ModLoader.addAllRenderers(ModLoader.java:161)
at net.minecraft.src.RenderManager.<init>(RenderManager.java:86)
at net.minecraft.src.RenderManager.<clinit>(RenderManager.java:14)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:404)
at net.minecraft.client.Minecraft.run(Minecraft.java:724)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at net.minecraft.src.mod_everythingMinecraft.<clinit>(mod_everythingMinecraft.java:11)
... 15 more
--- END ERROR REPORT 15b39d13 ----------
here is my mod_ file:
package net.minecraft.src;
public class mod_everythingMinecraft extends BaseMod
{
//Items
public static final Item CornCob = (new ItemFood(1004, 5, 0.4F, false)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/EverythingMC/Items/corncob2.png")).setTabToDisplayOn(CreativeTabs.tabFood).setItemName("CornCob");
public static final Item CornSeeds = new ItemCornSeeds (1005, mod_everythingMinecraft.Corn.blockID, Block.tilledField.blockID).setIconIndex(ModLoader.addOverride("/gui/items.png", "/EverythingMC/Items/cornseeds.png")).setItemName("CornSeeds");
//Blocks
public static final Block Corn = new BlockCorn (165, ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn.png")).setBlockName("Corn");
//Multi-Textured Blocks' ints
//Crops
//Corn
public static int Corn1 = ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn1.png");
public static int Corn2 = ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn2.png");
public static int Corn3 = ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn3.png");
public static int Corn4 = ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn4.png");
public static int Corn5 = ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn5.png");
public static int Corn6 = ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn6.png");
public void load()
{
//Blocks
//Corn
ModLoader.registerBlock(Corn);
ModLoader.addName(Corn, "Corn");
//Items
//Corn Cob
ModLoader.addName(CornCob, "Corn Cob");
//Corn Seeds
ModLoader.addName(CornSeeds, "Corn Seeds");
}
public String getVersion()
{
return "1.3.1";
}
}
here is my ItemCornSeeds file:
package net.minecraft.src;
public class ItemCornSeeds extends Item
{
/**
* The type of block this seed turns into (wheat or pumpkin stems for instance)
*/
private int blockType;
/** BlockID of the block the seeds can be planted on. */
private int soilBlockID;
public ItemCornSeeds(int par1, int par2, int par3)
{
super(par1);
this.blockType = par2;
this.soilBlockID = par3;
this.setTabToDisplayOn(CreativeTabs.tabMaterials);
}
public boolean tryPlaceIntoWorld(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
if (par7 != 1)
{
return false;
}
else if (par2EntityPlayer.canPlayerEdit(par4, par5, par6) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6))
{
int var11 = par3World.getBlockId(par4, par5, par6);
if (var11 == this.soilBlockID && par3World.isAirBlock(par4, par5 + 1, par6))
{
par3World.setBlockWithNotify(par4, par5 + 1, par6, this.blockType);
--par1ItemStack.stackSize;
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
}
here is my BlockCorn file:
package net.minecraft.src;
import java.util.Random;
public class BlockCorn extends BlockFlower
{
protected BlockCorn(int par1, int par2)
{
super(par1, par2);
this.blockIndexInTexture = par2;
this.setTickRandomly(true);
float var3 = 0.5F;
this.setBlockBounds(0.5F - var3, 0.0F, 0.5F - var3, 0.5F + var3, 0.25F, 0.5F + var3);
this.setCreativeTab((CreativeTabs)null);
}
/**
* Gets passed in the blockID of the block below and supposed to return true if its allowed to grow on the type of
* blockID passed in. Args: blockID
*/
protected boolean canThisPlantGrowOnThisBlockID(int par1)
{
return par1 == Block.tilledField.blockID;
}
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
super.updateTick(par1World, par2, par3, par4, par5Random);
if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9)
{
int var6 = par1World.getBlockMetadata(par2, par3, par4);
if (var6 < 6)
{
float var7 = this.getGrowthRate(par1World, par2, par3, par4);
if (par5Random.nextInt((int)(25.0F / var7) + 1) == 0)
{
++var6;
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6);
}
}
}
}
/**
* Apply bonemeal to the crops.
*/
public void fertilize(World par1World, int par2, int par3, int par4)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 7);
}
/**
* Gets the growth rate for the crop. Setup to encourage rows by halving growth rate if there is diagonals, crops on
* different sides that aren't opposing, and by adding growth for every crop next to this one (and for crop below
* this one). Args: x, y, z
*/
private float getGrowthRate(World par1World, int par2, int par3, int par4)
{
float var5 = 1.0F;
int var6 = par1World.getBlockId(par2, par3, par4 - 1);
int var7 = par1World.getBlockId(par2, par3, par4 + 1);
int var8 = par1World.getBlockId(par2 - 1, par3, par4);
int var9 = par1World.getBlockId(par2 + 1, par3, par4);
int var10 = par1World.getBlockId(par2 - 1, par3, par4 - 1);
int var11 = par1World.getBlockId(par2 + 1, par3, par4 - 1);
int var12 = par1World.getBlockId(par2 + 1, par3, par4 + 1);
int var13 = par1World.getBlockId(par2 - 1, par3, par4 + 1);
boolean var14 = var8 == this.blockID || var9 == this.blockID;
boolean var15 = var6 == this.blockID || var7 == this.blockID;
boolean var16 = var10 == this.blockID || var11 == this.blockID || var12 == this.blockID || var13 == this.blockID;
for (int var17 = par2 - 1; var17 <= par2 + 1; ++var17)
{
for (int var18 = par4 - 1; var18 <= par4 + 1; ++var18)
{
int var19 = par1World.getBlockId(var17, par3 - 1, var18);
float var20 = 0.0F;
if (var19 == Block.tilledField.blockID)
{
var20 = 1.0F;
if (par1World.getBlockMetadata(var17, par3 - 1, var18) > 0)
{
var20 = 3.0F;
}
}
if (var17 != par2 || var18 != par4)
{
var20 /= 4.0F;
}
var5 += var20;
}
}
if (var16 || var14 && var15)
{
var5 /= 2.0F;
}
return var5;
}
/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
*/
public int getBlockTextureFromSideAndMetadata(int par1, int par2)
{
if(par2 == 0)
{
return blockIndexInTexture;
}
if(par2 == 1)
{
return mod_everythingMinecraft.Corn1;
}
if(par2 == 2)
{
return mod_everythingMinecraft.Corn2;
}
if(par2 == 3)
{
return mod_everythingMinecraft.Corn3;
}
if(par2 == 4)
{
return mod_everythingMinecraft.Corn4;
}
if(par2 == 5)
{
return mod_everythingMinecraft.Corn5;
}
if(par2 == 6)
{
return mod_everythingMinecraft.Corn6;
}
return par2;
}
/**
* The type of render function that is called for this block
*/
public int getRenderType()
{
return 1;
}
/**
* Drops the block items with a specified chance of dropping the specified items
*/
public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
{
super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, 0);
if (!par1World.isRemote)
{
int var8 = 3 + par7;
for (int var9 = 0; var9 < var8; ++var9)
{
if (par1World.rand.nextInt(15) <= par5)
{
float var10 = 0.7F;
float var11 = par1World.rand.nextFloat() * var10 + (1.0F - var10) * 0.5F;
float var12 = par1World.rand.nextFloat() * var10 + (1.0F - var10) * 0.5F;
float var13 = par1World.rand.nextFloat() * var10 + (1.0F - var10) * 0.5F;
EntityItem var14 = new EntityItem(par1World, (double)((float)par2 + var11), (double)((float)par3 + var12), (double)((float)par4 + var13), new ItemStack(mod_everythingMinecraft.CornSeeds));
var14.delayBeforeCanPickup = 10;
par1World.spawnEntityInWorld(var14);
}
}
}
}
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3)
{
return par1 == 6 ? mod_everythingMinecraft.CornCob.shiftedIndex : -1;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random)
{
return 1;
}
/**
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
*/
public int idPicked(World par1World, int par2, int par3, int par4)
{
return mod_everythingMinecraft.CornSeeds.shiftedIndex;
}
}
I hope that wasnt too confusing.
Edit: Ooops, forgot to add in the code tags. Fixed. (I mean the not having code tags, NOT my problem tho)
hey i found a glitch or something but when i copy stuff it wont load properly for example:
i would copy the block code for mod_ and it would paste in 1 line like this
package net.minecraft.src yada yada until it is done
i am having a problem with adding a crop. i did a mash-up of the crop code in 1.3.1 and the tutorial code for the BlockCorn file. For the ItemCornSeeds file i just copied the ItemSeeds file in 1.3.1 and I followed this tutorial for the mod_ file. i had to put mod_everythingMinecraft.corn.blockID in the corn seeds public static line instead of in the tut where it said just to do corn.blockID (when i did that, i got an error) when i run MC with no errors in my code, MC crashes with a null pointer exception
here is my error:
Minecraft has crashed!
----------------------
Minecraft has stopped running because it encountered a problem; Exception occured in ModLoader
This error has been saved to C:\MCP's\MCP 1.3.1\jars\.\crash-reports\crash-2012-08-29_18.23.40-client.txt for your convenience. Please include a copy of this file if you report this crash to anyone.
--- BEGIN ERROR REPORT b2dc922d --------
Generated 8/29/12 6:23 PM
- Minecraft Version: 1.3.1
- Operating System: Windows 7 (amd64) version 6.1
- Java Version: 1.7.0_03, Oracle Corporation
- Java VM Version: Java HotSpot™ 64-Bit Server VM (mixed mode), Oracle Corporation
- Memory: 997418648 bytes (951 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB)
- JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
- ModLoader: Mods loaded: 1
ModLoader 1.3.1
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:353)
at net.minecraft.src.ModLoader.readFromClassPath(ModLoader.java:1344)
at net.minecraft.src.ModLoader.init(ModLoader.java:919)
at net.minecraft.src.ModLoader.addAllRenderers(ModLoader.java:161)
at net.minecraft.src.RenderManager.<init>(RenderManager.java:86)
at net.minecraft.src.RenderManager.<clinit>(RenderManager.java:14)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:404)
at net.minecraft.client.Minecraft.run(Minecraft.java:724)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at net.minecraft.src.mod_everythingMinecraft.<clinit>(mod_everythingMinecraft.java:11)
... 15 more
--- END ERROR REPORT 15b39d13 ----------
here is my mod_ file:
package net.minecraft.src;
public class mod_everythingMinecraft extends BaseMod
{
//Items
public static final Item CornCob = (new ItemFood(1004, 5, 0.4F, false)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/EverythingMC/Items/corncob2.png")).setTabToDisplayOn(CreativeTabs.tabFood).setItemName("CornCob");
public static final Item CornSeeds = new ItemCornSeeds (1005, mod_everythingMinecraft.Corn.blockID, Block.tilledField.blockID).setIconIndex(ModLoader.addOverride("/gui/items.png", "/EverythingMC/Items/cornseeds.png")).setItemName("CornSeeds");
//Blocks
public static final Block Corn = new BlockCorn (165, ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn.png")).setBlockName("Corn");
//Multi-Textured Blocks' ints
//Crops
//Corn
public static int Corn1 = ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn1.png");
public static int Corn2 = ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn2.png");
public static int Corn3 = ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn3.png");
public static int Corn4 = ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn4.png");
public static int Corn5 = ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn5.png");
public static int Corn6 = ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn6.png");
public void load()
{
//Blocks
//Corn
ModLoader.registerBlock(Corn);
ModLoader.addName(Corn, "Corn");
//Items
//Corn Cob
ModLoader.addName(CornCob, "Corn Cob");
//Corn Seeds
ModLoader.addName(CornSeeds, "Corn Seeds");
}
public String getVersion()
{
return "1.3.1";
}
}
here is my ItemCornSeeds file:
package net.minecraft.src;
public class ItemCornSeeds extends Item
{
/**
* The type of block this seed turns into (wheat or pumpkin stems for instance)
*/
private int blockType;
/** BlockID of the block the seeds can be planted on. */
private int soilBlockID;
public ItemCornSeeds(int par1, int par2, int par3)
{
super(par1);
this.blockType = par2;
this.soilBlockID = par3;
this.setTabToDisplayOn(CreativeTabs.tabMaterials);
}
public boolean tryPlaceIntoWorld(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
if (par7 != 1)
{
return false;
}
else if (par2EntityPlayer.canPlayerEdit(par4, par5, par6) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6))
{
int var11 = par3World.getBlockId(par4, par5, par6);
if (var11 == this.soilBlockID && par3World.isAirBlock(par4, par5 + 1, par6))
{
par3World.setBlockWithNotify(par4, par5 + 1, par6, this.blockType);
--par1ItemStack.stackSize;
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
}
here is my BlockCorn file:
package net.minecraft.src;
import java.util.Random;
public class BlockCorn extends BlockFlower
{
protected BlockCorn(int par1, int par2)
{
super(par1, par2);
this.blockIndexInTexture = par2;
this.setTickRandomly(true);
float var3 = 0.5F;
this.setBlockBounds(0.5F - var3, 0.0F, 0.5F - var3, 0.5F + var3, 0.25F, 0.5F + var3);
this.setCreativeTab((CreativeTabs)null);
}
/**
* Gets passed in the blockID of the block below and supposed to return true if its allowed to grow on the type of
* blockID passed in. Args: blockID
*/
protected boolean canThisPlantGrowOnThisBlockID(int par1)
{
return par1 == Block.tilledField.blockID;
}
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
super.updateTick(par1World, par2, par3, par4, par5Random);
if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9)
{
int var6 = par1World.getBlockMetadata(par2, par3, par4);
if (var6 < 6)
{
float var7 = this.getGrowthRate(par1World, par2, par3, par4);
if (par5Random.nextInt((int)(25.0F / var7) + 1) == 0)
{
++var6;
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6);
}
}
}
}
/**
* Apply bonemeal to the crops.
*/
public void fertilize(World par1World, int par2, int par3, int par4)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 7);
}
/**
* Gets the growth rate for the crop. Setup to encourage rows by halving growth rate if there is diagonals, crops on
* different sides that aren't opposing, and by adding growth for every crop next to this one (and for crop below
* this one). Args: x, y, z
*/
private float getGrowthRate(World par1World, int par2, int par3, int par4)
{
float var5 = 1.0F;
int var6 = par1World.getBlockId(par2, par3, par4 - 1);
int var7 = par1World.getBlockId(par2, par3, par4 + 1);
int var8 = par1World.getBlockId(par2 - 1, par3, par4);
int var9 = par1World.getBlockId(par2 + 1, par3, par4);
int var10 = par1World.getBlockId(par2 - 1, par3, par4 - 1);
int var11 = par1World.getBlockId(par2 + 1, par3, par4 - 1);
int var12 = par1World.getBlockId(par2 + 1, par3, par4 + 1);
int var13 = par1World.getBlockId(par2 - 1, par3, par4 + 1);
boolean var14 = var8 == this.blockID || var9 == this.blockID;
boolean var15 = var6 == this.blockID || var7 == this.blockID;
boolean var16 = var10 == this.blockID || var11 == this.blockID || var12 == this.blockID || var13 == this.blockID;
for (int var17 = par2 - 1; var17 <= par2 + 1; ++var17)
{
for (int var18 = par4 - 1; var18 <= par4 + 1; ++var18)
{
int var19 = par1World.getBlockId(var17, par3 - 1, var18);
float var20 = 0.0F;
if (var19 == Block.tilledField.blockID)
{
var20 = 1.0F;
if (par1World.getBlockMetadata(var17, par3 - 1, var18) > 0)
{
var20 = 3.0F;
}
}
if (var17 != par2 || var18 != par4)
{
var20 /= 4.0F;
}
var5 += var20;
}
}
if (var16 || var14 && var15)
{
var5 /= 2.0F;
}
return var5;
}
/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
*/
public int getBlockTextureFromSideAndMetadata(int par1, int par2)
{
if(par2 == 0)
{
return blockIndexInTexture;
}
if(par2 == 1)
{
return mod_everythingMinecraft.Corn1;
}
if(par2 == 2)
{
return mod_everythingMinecraft.Corn2;
}
if(par2 == 3)
{
return mod_everythingMinecraft.Corn3;
}
if(par2 == 4)
{
return mod_everythingMinecraft.Corn4;
}
if(par2 == 5)
{
return mod_everythingMinecraft.Corn5;
}
if(par2 == 6)
{
return mod_everythingMinecraft.Corn6;
}
return par2;
}
/**
* The type of render function that is called for this block
*/
public int getRenderType()
{
return 1;
}
/**
* Drops the block items with a specified chance of dropping the specified items
*/
public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
{
super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, 0);
if (!par1World.isRemote)
{
int var8 = 3 + par7;
for (int var9 = 0; var9 < var8; ++var9)
{
if (par1World.rand.nextInt(15) <= par5)
{
float var10 = 0.7F;
float var11 = par1World.rand.nextFloat() * var10 + (1.0F - var10) * 0.5F;
float var12 = par1World.rand.nextFloat() * var10 + (1.0F - var10) * 0.5F;
float var13 = par1World.rand.nextFloat() * var10 + (1.0F - var10) * 0.5F;
EntityItem var14 = new EntityItem(par1World, (double)((float)par2 + var11), (double)((float)par3 + var12), (double)((float)par4 + var13), new ItemStack(mod_everythingMinecraft.CornSeeds));
var14.delayBeforeCanPickup = 10;
par1World.spawnEntityInWorld(var14);
}
}
}
}
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3)
{
return par1 == 6 ? mod_everythingMinecraft.CornCob.shiftedIndex : -1;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random)
{
return 1;
}
/**
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
*/
public int idPicked(World par1World, int par2, int par3, int par4)
{
return mod_everythingMinecraft.CornSeeds.shiftedIndex;
}
}
I hope that wasnt too confusing.
Edit: Ooops, forgot to add in the code tags. Fixed. (I mean the not having code tags, NOT my problem tho)
Try putting the texture ints before the block is declared.
hey i found a glitch or something but when i copy stuff it wont load properly for example:
i would copy the block code for mod_ and it would paste in 1 line like this
package net.minecraft.src yada yada until it is done
any advice?
What IDE are you using?
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 know you most likely get sick of people asking for you to look at thier codes; but I have sat down and did the best I could, trying not to get to this last resource. I am not sure if you have heard of this "error" before; my Block does not show up, the thing is, there is not a single detected error in the coding (I use Eclipse):
Glasscraft_.java (For ModLoader)
package net.minecraft.src;
public class Glasscraft_ extends BaseMod
{
public void load()
{
}
public String getVersion()
{
return "1.3.2";
}
}
Glass_Stairs.java (First part of the .Class)
package net.minecraft.src;
public class Glass_Stairs extends BaseMod
{
public static final Block GlassStairs = new BlockGlass_Stairs (170, 0).setBlockName("GlassStairs").setHardness(0.3F).setResistance(1.5F).setLightValue(0F);
public void load()
{
GlassStairs.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/minecraft.jar/Glass.png");
ModLoader.registerBlock(GlassStairs);
ModLoader.addName(GlassStairs, "GlassStairs");
ModLoader.addRecipe(new ItemStack(GlassStairs, 4), new Object [] {" ", " # ", " ", Character.valueOf('#'), Block.glass});}
public String getVersion()
{
return "1.3.2";
}
}
BlockGlass_Stairs.java
package net.minecraft.src;
import java.util.List;
import java.util.Random;
public class BlockGlass_Stairs extends Block
{
public static final int[][] field_72159_a = new int[][] {{2, 6}, {3, 7}, {2, 3}, {6, 7}, {0, 4}, {1, 5}, {0, 1}, {4, 5}};
public boolean field_72156_cr = false;
private int field_72160_cs = 0;
protected BlockGlass_Stairs(int i, int j)
{
super(i, j, Material.glass);
this.setLightOpacity(0);
this.setCreativeTab(CreativeTabs.tabBlock);
}
public void setBlockBoundsBaseOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
if (this.field_72156_cr)
{
this.setBlockBounds(0.5F * (float)(this.field_72160_cs % 2), 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F * (float)(this.field_72160_cs / 4 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 4 % 2));
}
else
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
public boolean isOpaqueCube()
{
return false;
}
public boolean randerAsNormalBlock()
{
return false;
}
public int genRenderType()
{
return 10;
}
public void addCollidingBlockToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
{
int var8 = par1World.getBlockMetadata(par2, par3, par3);
int var9 = var8 & 3;
float var10 = 0.0f;
float var11 = 0.5f;
float var12 = 0.5f;
float var13 = 1.0f;
if ((var8 & 4) != 0)
{
var10 = 0.5f;
var11 = 1.0f;
var12 = 0.0f;
var13 = 0.5f;
}
this.setBlockBounds(0.0F, var10, 0.0F, 1.0F, var11, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
if (var9 == 0)
{
this.setBlockBounds(0.5F, var12, 0.0F, 1.0F, var13, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
else if (var9 == 1)
{
this.setBlockBounds(0.0F, var12, 0.0F, 0.5F, var13, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
else if (var9 == 2)
{
this.setBlockBounds(0.0F, var12, 0.5F, 1.0F, var13, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
else if (var9 == 3)
{
this.setBlockBounds(0.0F, var12, 0.0F, 1.0F, var13, 0.5F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
{
int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int var7 = par1World.getBlockMetadata(par2, par3, par4) & 4;
if (var6 == 0)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 2 | var7);
}
if (var6 == 1)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 1 | var7);
}
if (var6 == 2)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 3 | var7);
}
if (var6 == 3)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | var7);
}
}
public void updateBlockMetadata(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8)
{
if (par5 == 0 || par5 != 1 && (double)par7 > 0.5D)
{
int var9 = par1World.getBlockMetadata(par2, par3, par4);
par1World.setBlockMetadataWithNotify(par2, par3, par4, var9 | 4);
}
}
public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3)
{
MovingObjectPosition[] var7 = new MovingObjectPosition[8];
int var8 = par1World.getBlockMetadata(par2, par3, par4);
int var9 = var8 & 3;
boolean var10 = (var8 & 4) == 4;
int[] var11 = field_72159_a[var9 + (var10 ? 4 : 0)];
this.field_72156_cr = true;
int var14;
int var15;
int var16;
for (int var12 = 0; var12 < 8; ++var12)
{
this.field_72160_cs = var12;
int[] var13 = var11;
var14 = var11.length;
for (var15 = 0; var15 < var14; ++var15)
{
var16 = var13[var15];
if (var16 == var12)
{
;
}
}
var7[var12] = super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3);
}
int[] var21 = var11;
int var24 = var11.length;
for (var14 = 0; var14 < var24; ++var14)
{
var15 = var21[var14];
var7[var15] = null;
}
MovingObjectPosition var23 = null;
double var22 = 0.0D;
MovingObjectPosition[] var25 = var7;
var16 = var7.length;
for (int var17 = 0; var17 < var16; ++var17)
{
MovingObjectPosition var18 = var25[var17];
if (var18 != null)
{
double var19 = var18.hitVec.squareDistanceTo(par6Vec3);
if (var19 > var22)
{
var23 = var18;
var22 = var19;
}
}
}
return var23;
}
}
I want my block Ore to drop a custom item, The item is working, and I did what the instructions were to change what your block drops, but it's only dropping itself. What do I do?
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Thanks! That helped
Does anyone know which class the furnace fuels are located? (I'm not referring to FurnaceRecipes)
Block
package net.minecraft.src; import java.util.Random; public class BlockOpiumBlock extends BlockFlower { public BlockOpiumBlock(int i, int j) { super(i, j); blockIndexInTexture = j; setTickRandomly(true); float f = 0.5F; setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f); } /** * Gets passed in the blockID of the block below and supposed to return true if its allowed to grow on the type of * blockID passed in. Args: blockID. * This basically checks to see if the block below is a tilled field/tilled dirt. If it is true then the crop can grow. */ protected boolean canThisPlantGrowOnThisBlockID(int par1) { return par1 == Block.tilledField.blockID; } /** * Ticks the block if it's been scheduled. This method gets scheduled to run because of the setTickRandomly part in the constructor of the class. */ public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { super.updateTick(par1World, par2, par3, par4, par5Random); if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9) { int i = par1World.getBlockMetadata(par2, par3, par4); if (i < 3) { float f = getGrowthRate(par1World, par2, par3, par4); if (par5Random.nextInt((int)(25F / f) + 1) == 0) { i++; par1World.setBlockMetadataWithNotify(par2, par3, par4, i); } } } } /** * This method allows you to use bonemeal on your crop. Code explanation below: ItemStack itemstack = entityplayer.inventory.getCurrentItem(); - This line makes "itemstack" equal to the item currently in the players hand. if(itemstack != null && itemstack.itemID == Item.dyePowder.shiftedIndex) - This line checks if the item in players hand is equal to dye. if(itemstack.getItemDamage() == 15) - This line checks if the damage value of that item is 15. Item.dyePowder's damage value of 15 is bonemeal. world.setBlockMetadataWithNotify(i, j, k, 8); - This line sets the metadata value of the block to 8 which is the final growth stage. itemstack.stackSize--; - This line makes the stack size go down by one. world.notifyBlockChange(i, j, k, 0); - This line notifys adjacent blocks that this block has updated its state. */ public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { ItemStack itemstack = par5EntityPlayer.inventory.getCurrentItem(); if(itemstack != null && itemstack.itemID == Item.dyePowder.shiftedIndex) { if(itemstack.getItemDamage() == 15) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 8); itemstack.stackSize--; par1World.notifyBlockChange(par2, par3, par4, 0); } } super.onBlockActivated(par1World, par2, par3, par4, par5EntityPlayer, par6, par7, par8, par9); return true; } /** * Gets the growth rate for the crop. Setup to encourage rows by halving growth rate if there is diagonals, crops on * different sides that aren't opposing, and by adding growth for every crop next to this one (and for crop below * this one). Args: x, y, z */ private float getGrowthRate(World par1World, int par2, int par3, int par4) { float f = 1.0F; int i = par1World.getBlockId(par2, par3, par4 - 1); int j = par1World.getBlockId(par2, par3, par4 + 1); int k = par1World.getBlockId(par2 - 1, par3, par4); int l = par1World.getBlockId(par2 + 1, par3, par4); int i1 = par1World.getBlockId(par2 - 1, par3, par4 - 1); int j1 = par1World.getBlockId(par2 + 1, par3, par4 - 1); int k1 = par1World.getBlockId(par2 + 1, par3, par4 + 1); int l1 = par1World.getBlockId(par2 - 1, par3, par4 + 1); boolean flag = k == blockID || l == blockID; boolean flag1 = i == blockID || j == blockID; boolean flag2 = i1 == blockID || j1 == blockID || k1 == blockID || l1 == blockID; for (int i2 = par2 - 1; i2 <= par2 + 1; i2++) { for (int j2 = par4 - 1; j2 <= par4 + 1; j2++) { int k2 = par1World.getBlockId(i2, par3 - 1, j2); float f1 = 0.0F; if (k2 == Block.tilledField.blockID) { f1 = 1.0F; if (par1World.getBlockMetadata(i2, par3 - 1, j2) > 0) { f1 = 3F; } } if (i2 != par2 || j2 != par4) { f1 /= 4F; } f += f1; } } if (flag2 || flag && flag1) { f /= 2.0F; } return f; } /** * The type of render function that is called for this block. The render type of 6 gets the texture and places it four times around the sides of the block and leaves nothing on the top or bottom. */ public int getRenderType() { return 6; } /** * Drops the block items with a specified chance of dropping the specified items */ public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7) { super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, 0); if (par1World.isRemote) { return; } int i = 3 + par7; for (int j = 0; j < i; j++) { if (par1World.rand.nextInt(15) <= par5) { float f = 0.7F; float f1 = par1World.rand.nextFloat() * f + (1.0F - f) * 0.5F; float f2 = par1World.rand.nextFloat() * f + (1.0F - f) * 0.5F; float f3 = par1World.rand.nextFloat() * f + (1.0F - f) * 0.5F; EntityItem entityitem = new EntityItem(par1World, (float)par2 + f1, (float)par3 + f2, (float)par4 + f3, new ItemStack(mod_MUI.opiumseeds)); entityitem.delayBeforeCanPickup = 10; par1World.spawnEntityInWorld(entityitem); } } } /** * Returns the ID of the items to drop on destruction. "i" is equal to the blocks metadata value(explained slightly more in the getBlockTextureFromSideAndMetadata method below). This means that it will check that that value is equal to 8(the final stage of growth) and if it is then it will drop wheat. It may be fairly obvious, but the 'else' statement means that if the growth state is not equal to 7 then drop nothing (-1 means nothing) */ public int idDropped(int i, Random random, int j) { if (i == 8) { return Item.wheat.shiftedIndex; } else { return -1; } } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random random) { return 1; } /** * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata. * As you may have been able to tell from the line above, "j" is equal to the metadata value of the block. This checks if that value is equal to a certain number then sets the blocks texture to what you have defined. * The things that are being returned are the ints in your mod_ class which you created and set to your texture for the specific stages of growth. */ public int getBlockTextureFromSideAndMetadata(int i, int j) { if(j == 0) { return blockIndexInTexture; } if(j == 1) { return mod_MUI.opiumstageone; } if(j == 2) { return mod_MUI.opiumstagetwo; } if(j == 3) { return mod_MUI.opiumstagethree; } return j; } }package net.minecraft.src; public class ItemOpiumSeeds extends Item { /** The type of block this seed turns into (wheat or pumpkin stems for instance)*/ private int blockType; /** BlockID of the block the seeds can be planted on. */ private int soilBlockID; public ItemOpiumSeeds(int i, int j, int k) { super(i); blockType = j; soilBlockID = k; } /** * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return * True if something happen and false if it don't. This is for ITEMS, not BLOCKS ! */ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7) { if (par7 != 1) { return false; } if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6) || !par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6)) { return false; } int i = par3World.getBlockId(par4, par5, par6); if (i == soilBlockID && par3World.isAirBlock(par4, par5 + 1, par6)) { par3World.setBlockWithNotify(par4, par5 + 1, par6, blockType); par1ItemStack.stackSize--; return true; } else { return false; } } }Post your mod_ code.
together they are powerful beyond imagination."
TileEntityFurnace.
together they are powerful beyond imagination."
package net.minecraft.src; import java.util.Random; public class mod_MUI extends BaseMod { //OPIUM CROP SETUP public static final Block opiumblock = new BlockOpiumBlock(165, 0).setBlockName("opiumblock"); public static final Item opiumseeds = new ItemOpiumSeeds(2500, opiumblock.blockID, Block.tilledField.blockID).setItemName("opiumseeds"); //CROP STAGES public static int opiumstageone = ModLoader.addOverride("/terrain.png", "/crops/opiumstageone.png"); public static int opiumstagetwo = ModLoader.addOverride("/terrain.png", "/crops/opiumstagetwo.png"); public static int opiumstagethree = ModLoader.addOverride("/terrain.png", "/crops/opiumstagethree.png"); public void load() { ///////// //CROPS// ///////// opiumblock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/opoppy.png"); ModLoader.registerBlock(opiumblock); ModLoader.addName(opiumblock, "Opium Poppy"); opiumseeds.iconIndex = ModLoader.addOverride("/gui/items.png", "/opiumseeds.png"); ModLoader.addName(opiumseeds, "Opium Poppy Seeds"); opiumseeds.setTabToDisplayOn(CreativeTabs.tabMaterials); } public String getVersion() { return "0.1a"; } }public class mod_WereWolf extends BaseMod{ private Set trackedEntities = new HashSet(); public Timer timer; public WorldProvider provider; public World world; public static boolean isInfected; public static final Block silverOre = new Block(200, 0, Material.iron).setHardness(3.0F).setResistance(5.0F).setCreativeTab(CreativeTabs.tabBlock).setBlockName("oreSilver"); public static final Item ringNight = new Item(2200).setTabToDisplayOn(CreativeTabs.tabTools).setItemName("ringNight"); public KeyBinding key_test = new KeyBinding("keyTest", Keyboard.KEY_U); public static boolean iswolf; public void keyboardEvent(KeyBinding keybinding) { if(keybinding == this.key_test) { iswolf = !iswolf; } } @Override public void load() { //Textures ringNight.iconIndex = ModLoader.addOverride("/gui/items.png", "/WW/Ring.png"); silverOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/WW/Ore.png"); ModLoader.registerBlock(silverOre); //names ModLoader.addName(silverOre, "Silver Ore"); ModLoader.addName(ringNight, "Ring of Night"); ModLoader.registerEntityID(EntityWerewolf.class, "Werewolf", -128); ModLoader.addSpawn(EntityWerewolf.class, 2, 1, 3, EnumCreatureType.monster); ModLoader.setInGameHook(this, true, false); ModLoader.registerKey(this, this.key_test, false); }package net.minecraft.src; public class mod_VolcanicItems extends BaseMod{ public static final Block volcBlock = new BlockVolcanite(160, 0).setBlockName("vblock").setHardness(2F).setResistance(6F).setStepSound(Block.soundStoneFootstep).setCreativeTab(CreativeTabs.tabBlock); public static final Item vshard = new ItemVolcanicShard(5000).setItemName("vshard"); public static final Block vglassBlock = new BlockVolcanicGlass(161, 0).setBlockName("vglass").setHardness(1F).setResistance(3F).setCreativeTab(CreativeTabs.tabDeco); public void load() { volcBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/gtf/volcanoblock.png"); vshard.iconIndex = ModLoader.addOverride("/gui/items.png", "/gtf/volcanicshard.png"); ModLoader.registerBlock(volcBlock); ModLoader.addName(volcBlock, "Volcanite"); ModLoader.addName(vshard, "Volcanic Shard"); ModLoader.addRecipe(new ItemStack(volcBlock, 1), new Object [] {"###", "###", "###", Character.valueOf('#'), vshard.shiftedIndex}); } public String getVersion() { return "For Minecraft 1.3.2 for Ocelot-kun"; } }im gay
The seed class in the tutorial has been updated.
Are you asking how to make it displayinstead of
?
No error = no help.
together they are powerful beyond imagination."
When I get around to it. Probably in a few weeks. Working on fixing some of these up first.
together they are powerful beyond imagination."
Thanks it works! However there is still one issue, with the same code as previously posted the plants don't actually grow. If I place seeds in tilled dirt then they instantly end up at the 3rd form and can be harvested. How can I fix this?
Yep I forgot what the full entity.ENTITYHERE.name was
Both these posts got buried...
Use:
ModLoader.addLocalization("entity.entityName.name", "Name");Example:ModLoader.addLocalization("entity.Werewolf.name", "Werewolf");Add .setStepSound(Block.soundGrassFootstep) to the public static final line of the block. You can change the sound to any sound in Block.
Diamond is 1.
I can't seem to reproduce the error at the moment. I'll try again tomorrow, remind me if I forget and don't reply.
together they are powerful beyond imagination."
Edit: never mind, I can just use the cactus one. But it won't damage me when I step on it. Here is the code that should make it damage any mob that steps on it:
public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity) { entity.attackEntityFrom(DamageSource.cactus, 1); }here is my error:
here is my mod_ file:
package net.minecraft.src; public class mod_everythingMinecraft extends BaseMod { //Items public static final Item CornCob = (new ItemFood(1004, 5, 0.4F, false)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/EverythingMC/Items/corncob2.png")).setTabToDisplayOn(CreativeTabs.tabFood).setItemName("CornCob"); public static final Item CornSeeds = new ItemCornSeeds (1005, mod_everythingMinecraft.Corn.blockID, Block.tilledField.blockID).setIconIndex(ModLoader.addOverride("/gui/items.png", "/EverythingMC/Items/cornseeds.png")).setItemName("CornSeeds"); //Blocks public static final Block Corn = new BlockCorn (165, ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn.png")).setBlockName("Corn"); //Multi-Textured Blocks' ints //Crops //Corn public static int Corn1 = ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn1.png"); public static int Corn2 = ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn2.png"); public static int Corn3 = ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn3.png"); public static int Corn4 = ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn4.png"); public static int Corn5 = ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn5.png"); public static int Corn6 = ModLoader.addOverride("/terrain.png", "/EverythingMC/Blocks/corn6.png"); public void load() { //Blocks //Corn ModLoader.registerBlock(Corn); ModLoader.addName(Corn, "Corn"); //Items //Corn Cob ModLoader.addName(CornCob, "Corn Cob"); //Corn Seeds ModLoader.addName(CornSeeds, "Corn Seeds"); } public String getVersion() { return "1.3.1"; } }here is my ItemCornSeeds file:
package net.minecraft.src; public class ItemCornSeeds extends Item { /** * The type of block this seed turns into (wheat or pumpkin stems for instance) */ private int blockType; /** BlockID of the block the seeds can be planted on. */ private int soilBlockID; public ItemCornSeeds(int par1, int par2, int par3) { super(par1); this.blockType = par2; this.soilBlockID = par3; this.setTabToDisplayOn(CreativeTabs.tabMaterials); } public boolean tryPlaceIntoWorld(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (par7 != 1) { return false; } else if (par2EntityPlayer.canPlayerEdit(par4, par5, par6) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6)) { int var11 = par3World.getBlockId(par4, par5, par6); if (var11 == this.soilBlockID && par3World.isAirBlock(par4, par5 + 1, par6)) { par3World.setBlockWithNotify(par4, par5 + 1, par6, this.blockType); --par1ItemStack.stackSize; return true; } else { return false; } } else { return false; } } }here is my BlockCorn file:
package net.minecraft.src; import java.util.Random; public class BlockCorn extends BlockFlower { protected BlockCorn(int par1, int par2) { super(par1, par2); this.blockIndexInTexture = par2; this.setTickRandomly(true); float var3 = 0.5F; this.setBlockBounds(0.5F - var3, 0.0F, 0.5F - var3, 0.5F + var3, 0.25F, 0.5F + var3); this.setCreativeTab((CreativeTabs)null); } /** * Gets passed in the blockID of the block below and supposed to return true if its allowed to grow on the type of * blockID passed in. Args: blockID */ protected boolean canThisPlantGrowOnThisBlockID(int par1) { return par1 == Block.tilledField.blockID; } /** * Ticks the block if it's been scheduled */ public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { super.updateTick(par1World, par2, par3, par4, par5Random); if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9) { int var6 = par1World.getBlockMetadata(par2, par3, par4); if (var6 < 6) { float var7 = this.getGrowthRate(par1World, par2, par3, par4); if (par5Random.nextInt((int)(25.0F / var7) + 1) == 0) { ++var6; par1World.setBlockMetadataWithNotify(par2, par3, par4, var6); } } } } /** * Apply bonemeal to the crops. */ public void fertilize(World par1World, int par2, int par3, int par4) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 7); } /** * Gets the growth rate for the crop. Setup to encourage rows by halving growth rate if there is diagonals, crops on * different sides that aren't opposing, and by adding growth for every crop next to this one (and for crop below * this one). Args: x, y, z */ private float getGrowthRate(World par1World, int par2, int par3, int par4) { float var5 = 1.0F; int var6 = par1World.getBlockId(par2, par3, par4 - 1); int var7 = par1World.getBlockId(par2, par3, par4 + 1); int var8 = par1World.getBlockId(par2 - 1, par3, par4); int var9 = par1World.getBlockId(par2 + 1, par3, par4); int var10 = par1World.getBlockId(par2 - 1, par3, par4 - 1); int var11 = par1World.getBlockId(par2 + 1, par3, par4 - 1); int var12 = par1World.getBlockId(par2 + 1, par3, par4 + 1); int var13 = par1World.getBlockId(par2 - 1, par3, par4 + 1); boolean var14 = var8 == this.blockID || var9 == this.blockID; boolean var15 = var6 == this.blockID || var7 == this.blockID; boolean var16 = var10 == this.blockID || var11 == this.blockID || var12 == this.blockID || var13 == this.blockID; for (int var17 = par2 - 1; var17 <= par2 + 1; ++var17) { for (int var18 = par4 - 1; var18 <= par4 + 1; ++var18) { int var19 = par1World.getBlockId(var17, par3 - 1, var18); float var20 = 0.0F; if (var19 == Block.tilledField.blockID) { var20 = 1.0F; if (par1World.getBlockMetadata(var17, par3 - 1, var18) > 0) { var20 = 3.0F; } } if (var17 != par2 || var18 != par4) { var20 /= 4.0F; } var5 += var20; } } if (var16 || var14 && var15) { var5 /= 2.0F; } return var5; } /** * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata */ public int getBlockTextureFromSideAndMetadata(int par1, int par2) { if(par2 == 0) { return blockIndexInTexture; } if(par2 == 1) { return mod_everythingMinecraft.Corn1; } if(par2 == 2) { return mod_everythingMinecraft.Corn2; } if(par2 == 3) { return mod_everythingMinecraft.Corn3; } if(par2 == 4) { return mod_everythingMinecraft.Corn4; } if(par2 == 5) { return mod_everythingMinecraft.Corn5; } if(par2 == 6) { return mod_everythingMinecraft.Corn6; } return par2; } /** * The type of render function that is called for this block */ public int getRenderType() { return 1; } /** * Drops the block items with a specified chance of dropping the specified items */ public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7) { super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, 0); if (!par1World.isRemote) { int var8 = 3 + par7; for (int var9 = 0; var9 < var8; ++var9) { if (par1World.rand.nextInt(15) <= par5) { float var10 = 0.7F; float var11 = par1World.rand.nextFloat() * var10 + (1.0F - var10) * 0.5F; float var12 = par1World.rand.nextFloat() * var10 + (1.0F - var10) * 0.5F; float var13 = par1World.rand.nextFloat() * var10 + (1.0F - var10) * 0.5F; EntityItem var14 = new EntityItem(par1World, (double)((float)par2 + var11), (double)((float)par3 + var12), (double)((float)par4 + var13), new ItemStack(mod_everythingMinecraft.CornSeeds)); var14.delayBeforeCanPickup = 10; par1World.spawnEntityInWorld(var14); } } } } /** * Returns the ID of the items to drop on destruction. */ public int idDropped(int par1, Random par2Random, int par3) { return par1 == 6 ? mod_everythingMinecraft.CornCob.shiftedIndex : -1; } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random par1Random) { return 1; } /** * only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative) */ public int idPicked(World par1World, int par2, int par3, int par4) { return mod_everythingMinecraft.CornSeeds.shiftedIndex; } }I hope that wasnt too confusing.
Edit: Ooops, forgot to add in the code tags.
Be sure to check out my texture pack: Easy Ores!
i would copy the block code for mod_ and it would paste in 1 line like this
package net.minecraft.src yada yada until it is done
any advice?
Try putting the texture ints before the block is declared.
What IDE are you using?
together they are powerful beyond imagination."
Glasscraft_.java (For ModLoader)
package net.minecraft.src; public class Glasscraft_ extends BaseMod { public void load() { } public String getVersion() { return "1.3.2"; } }Glass_Stairs.java (First part of the .Class)
package net.minecraft.src; public class Glass_Stairs extends BaseMod { public static final Block GlassStairs = new BlockGlass_Stairs (170, 0).setBlockName("GlassStairs").setHardness(0.3F).setResistance(1.5F).setLightValue(0F); public void load() { GlassStairs.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/minecraft.jar/Glass.png"); ModLoader.registerBlock(GlassStairs); ModLoader.addName(GlassStairs, "GlassStairs"); ModLoader.addRecipe(new ItemStack(GlassStairs, 4), new Object [] {" ", " # ", " ", Character.valueOf('#'), Block.glass});} public String getVersion() { return "1.3.2"; } }BlockGlass_Stairs.java
package net.minecraft.src; import java.util.List; import java.util.Random; public class BlockGlass_Stairs extends Block { public static final int[][] field_72159_a = new int[][] {{2, 6}, {3, 7}, {2, 3}, {6, 7}, {0, 4}, {1, 5}, {0, 1}, {4, 5}}; public boolean field_72156_cr = false; private int field_72160_cs = 0; protected BlockGlass_Stairs(int i, int j) { super(i, j, Material.glass); this.setLightOpacity(0); this.setCreativeTab(CreativeTabs.tabBlock); } public void setBlockBoundsBaseOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { if (this.field_72156_cr) { this.setBlockBounds(0.5F * (float)(this.field_72160_cs % 2), 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F * (float)(this.field_72160_cs / 4 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 4 % 2)); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } } public boolean isOpaqueCube() { return false; } public boolean randerAsNormalBlock() { return false; } public int genRenderType() { return 10; } public void addCollidingBlockToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) { int var8 = par1World.getBlockMetadata(par2, par3, par3); int var9 = var8 & 3; float var10 = 0.0f; float var11 = 0.5f; float var12 = 0.5f; float var13 = 1.0f; if ((var8 & 4) != 0) { var10 = 0.5f; var11 = 1.0f; var12 = 0.0f; var13 = 0.5f; } this.setBlockBounds(0.0F, var10, 0.0F, 1.0F, var11, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); if (var9 == 0) { this.setBlockBounds(0.5F, var12, 0.0F, 1.0F, var13, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } else if (var9 == 1) { this.setBlockBounds(0.0F, var12, 0.0F, 0.5F, var13, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } else if (var9 == 2) { this.setBlockBounds(0.0F, var12, 0.5F, 1.0F, var13, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } else if (var9 == 3) { this.setBlockBounds(0.0F, var12, 0.0F, 1.0F, var13, 0.5F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving) { int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; int var7 = par1World.getBlockMetadata(par2, par3, par4) & 4; if (var6 == 0) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 2 | var7); } if (var6 == 1) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 1 | var7); } if (var6 == 2) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 3 | var7); } if (var6 == 3) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | var7); } } public void updateBlockMetadata(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8) { if (par5 == 0 || par5 != 1 && (double)par7 > 0.5D) { int var9 = par1World.getBlockMetadata(par2, par3, par4); par1World.setBlockMetadataWithNotify(par2, par3, par4, var9 | 4); } } public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3) { MovingObjectPosition[] var7 = new MovingObjectPosition[8]; int var8 = par1World.getBlockMetadata(par2, par3, par4); int var9 = var8 & 3; boolean var10 = (var8 & 4) == 4; int[] var11 = field_72159_a[var9 + (var10 ? 4 : 0)]; this.field_72156_cr = true; int var14; int var15; int var16; for (int var12 = 0; var12 < 8; ++var12) { this.field_72160_cs = var12; int[] var13 = var11; var14 = var11.length; for (var15 = 0; var15 < var14; ++var15) { var16 = var13[var15]; if (var16 == var12) { ; } } var7[var12] = super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3); } int[] var21 = var11; int var24 = var11.length; for (var14 = 0; var14 < var24; ++var14) { var15 = var21[var14]; var7[var15] = null; } MovingObjectPosition var23 = null; double var22 = 0.0D; MovingObjectPosition[] var25 = var7; var16 = var7.length; for (int var17 = 0; var17 < var16; ++var17) { MovingObjectPosition var18 = var25[var17]; if (var18 != null) { double var19 = var18.hitVec.squareDistanceTo(par6Vec3); if (var19 > var22) { var23 = var18; var22 = var19; } } } return var23; } }