This site works best with JavaScript enabled. Please enable JavaScript to get the best experience from this site.
package net.minecraft.src; import java.util.*; import net.minecraft.client.Minecraft; public class mod_NewDiscovery extends BaseMod { private Minecraft mc = ModLoader.getMinecraftInstance(); float f1; float maxnum = 10.0F; float burnc = 10.0F; private boolean running = true; protected Random randomGenerator; public static final Item BSword = new ItemSword(990, EnumToolMaterial.Blackened).setItemName("bbba"); public static final Block Bore = new BlockBore(151, 0).setHardness(10F).setResistance(5F).setBlockName("bbbb"); public static final Item MIron = new ItemMIron(992).setItemName("bbbc"); public static final Item Bdust = new ItemBdust(993).setItemName("bbbd"); public static final Item BIron = new ItemBIron(994).setItemName("bbbe"); public static final Item BAxe = new ItemAxe(995, EnumToolMaterial.Blackened).setItemName("bbbf"); public static final Item BPick = new ItemPickaxe(996, EnumToolMaterial.Blackened).setItemName("bbbg"); public static final Item BSpade = new ItemSpade(997, EnumToolMaterial.Blackened).setItemName("bbbh"); public static final Item BHoe = new ItemHoe(998, EnumToolMaterial.Blackened).setItemName("bbbi"); public static final Item BHead = new ItemArmor(999, EnumArmorMaterial.BLACKENED, 5, 0).setItemName("bbbj"); public static final Item BChest = new ItemArmor(1535, EnumArmorMaterial.BLACKENED, 5, 1).setItemName("bbbk"); public static final Item BLeg = new ItemArmor(1536, EnumArmorMaterial.BLACKENED, 5, 2).setItemName("bbbl"); public static final Item BBoot = new ItemArmor(1537, EnumArmorMaterial.BLACKENED, 5, 3).setItemName("bbbm"); Random rr = new Random(); public String getVersion() { return "0.01"; } public boolean onTickInGame(float f, Minecraft mc) { if (mc.thePlayer.isSwinging ) { if (mc.thePlayer.getItemInUse().itemID == (BPick.shiftedIndex | BSword.shiftedIndex | BAxe.shiftedIndex | BHoe.shiftedIndex | BSpade.shiftedIndex)) { // this line and the above one ( they are the same line in my actual code) f1 = rr.nextFloat(); if(f1 > maxnum) f1 = 10.0F; if(f1 <= burnc){ mc.thePlayer.setFire(3); } } } return true; } @Override public void load() { ModLoader.setInGameHook(this, true, true); BHead.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/BlackenedHelmet.png"); ModLoader.addName(BHead, "Blackened Helmet"); ModLoader.addRecipe(new ItemStack(BHead, 1), new Object[] { "***", "* *", " ", '*', BIron }); BChest.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/BlackenedChestplate.png"); ModLoader.addName(BChest, "Blackened Chestplate"); ModLoader.addRecipe(new ItemStack(BChest, 1), new Object[] { "* *", "***", "***", '*', BIron }); BLeg.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/BlackenedPants.png"); ModLoader.addName(BLeg, "Blackened Leggings"); ModLoader.addRecipe(new ItemStack(BLeg, 1), new Object[] { "***", "* *", "* *", '*', BIron }); BBoot.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/BlackenedBoots.png"); ModLoader.addName(BBoot, "Blackened Boots"); ModLoader.addRecipe(new ItemStack(BBoot, 1), new Object[] { " ", "* *", "* *", '*', BIron }); MIron.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/LiquidIron.png"); ModLoader.addName(MIron, "Melted Iron"); ModLoader.addSmelting(Item.ingotIron.shiftedIndex, new ItemStack(MIron, 1)); BIron.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/BlackenedIronIngot.png"); ModLoader.addName(BIron, "Blackened Iron"); ModLoader.addRecipe(new ItemStack(BIron, 2), new Object[] { "^^^", " # ", " @ ", '^', Bdust, '#', MIron, '@', Item.bucketWater }); BSword.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/Blackened Sword.png"); ModLoader.addName(BSword, "Blackened Sword"); ModLoader.addRecipe(new ItemStack(BSword, 1), new Object[] { " * ", " * ", " $ ", '*', BIron, '$', Item.stick }); BPick.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/BlackenedPickaxe.png"); ModLoader.addName(BPick, "Blackened Pickaxe"); ModLoader.addRecipe(new ItemStack(BPick, 1), new Object[] { "***", " $ ", " $ ", '*', BIron, '$', Item.stick }); BAxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/BlackenedAxe.png"); ModLoader.addName(BAxe, "Blackened Axe"); ModLoader.addRecipe(new ItemStack(BAxe, 1), new Object[] { "** ", "*$ ", " $ ", '*', BIron, '$', Item.stick }); BSpade.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/BlackenedShovel.png"); ModLoader.addName(BSpade, "Blackened Shovel"); ModLoader.addRecipe(new ItemStack(BSpade, 1), new Object[] { " * ", " $ ", " $ ", '*', BIron, '$', Item.stick }); BHoe.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/BlackenedHoe.png"); ModLoader.addName(BHoe, "Blackened Hoe"); ModLoader.addRecipe(new ItemStack(BHoe, 1), new Object[] { "** ", " $ ", " $ ", '*', BIron, '$', Item.stick }); ModLoader.registerBlock(Bore); Bore.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/Ores/Bore.png"); ModLoader.addName(Bore, "Blation Ore"); Bdust.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/bsdust.png"); ModLoader.addName(Bdust, "Blation Dust"); ModLoader.addArmor("BLACKENED"); } public void generateSurface(World world, Random random, int chunkX, int chunkZ) { randomGenerator = random; for (int i = 0; i < 25; i++) { int randPosX = chunkX + randomGenerator.nextInt(16); int randPosY = random.nextInt(80); int randPosZ = chunkZ + randomGenerator.nextInt(16); (new WorldGenMinable(Bore.blockID, 20)).generate(world, random, randPosX, randPosY, randPosZ); } } }
Quote from UselessFlaw ok how do I keep that insurance in case f1 is larger than maxnum, because the number is defined by a random object why is f1 never larger?
package net.minecraft.src; import java.util.*; import net.minecraft.client.Minecraft; public class mod_NewDiscovery extends BaseMod { private Minecraft mc = ModLoader.getMinecraftInstance(); float f1; float burnc = 1.0F; private boolean running = true; protected Random randomGenerator; public static final Item BSword = new ItemSword(990, EnumToolMaterial.Blackened).setItemName("bbba"); public static final Block Bore = new BlockBore(151, 0).setHardness(10F).setResistance(5F).setBlockName("bbbb"); public static final Item MIron = new ItemMIron(992).setItemName("bbbc"); public static final Item Bdust = new ItemBdust(993).setItemName("bbbd"); public static final Item BIron = new ItemBIron(994).setItemName("bbbe"); public static final Item BAxe = new ItemAxe(995, EnumToolMaterial.Blackened).setItemName("bbbf"); public static final Item BPick = new ItemPickaxe(996, EnumToolMaterial.Blackened).setItemName("bbbg"); public static final Item BSpade = new ItemSpade(997, EnumToolMaterial.Blackened).setItemName("bbbh"); public static final Item BHoe = new ItemHoe(998, EnumToolMaterial.Blackened).setItemName("bbbi"); public static final Item BHead = new ItemArmor(999, EnumArmorMaterial.BLACKENED, 5, 0).setItemName("bbbj"); public static final Item BChest = new ItemArmor(1535, EnumArmorMaterial.BLACKENED, 5, 1).setItemName("bbbk"); public static final Item BLeg = new ItemArmor(1536, EnumArmorMaterial.BLACKENED, 5, 2).setItemName("bbbl"); public static final Item BBoot = new ItemArmor(1537, EnumArmorMaterial.BLACKENED, 5, 3).setItemName("bbbm"); Random rr = new Random(); public String getVersion() { return "0.01"; } public boolean onTickInGame(float f, Minecraft mc) { if (mc.thePlayer.isSwinging ) { if (mc.thePlayer.getItemInUse() != null && mc.thePlayer.getItemInUse().itemID == (BPick.shiftedIndex | BSword.shiftedIndex | BAxe.shiftedIndex | BHoe.shiftedIndex | BSpade.shiftedIndex)) { f1 = rr.nextFloat(); if(f1 <= burnc){ mc.thePlayer.setFire(3); } } } return true; } @Override public void load() { ModLoader.setInGameHook(this, true, true); BHead.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/BlackenedHelmet.png"); ModLoader.addName(BHead, "Blackened Helmet"); ModLoader.addRecipe(new ItemStack(BHead, 1), new Object[] { "***", "* *", " ", '*', BIron }); BChest.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/BlackenedChestplate.png"); ModLoader.addName(BChest, "Blackened Chestplate"); ModLoader.addRecipe(new ItemStack(BChest, 1), new Object[] { "* *", "***", "***", '*', BIron }); BLeg.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/BlackenedPants.png"); ModLoader.addName(BLeg, "Blackened Leggings"); ModLoader.addRecipe(new ItemStack(BLeg, 1), new Object[] { "***", "* *", "* *", '*', BIron }); BBoot.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/BlackenedBoots.png"); ModLoader.addName(BBoot, "Blackened Boots"); ModLoader.addRecipe(new ItemStack(BBoot, 1), new Object[] { " ", "* *", "* *", '*', BIron }); MIron.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/LiquidIron.png"); ModLoader.addName(MIron, "Melted Iron"); ModLoader.addSmelting(Item.ingotIron.shiftedIndex, new ItemStack(MIron, 1)); BIron.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/BlackenedIronIngot.png"); ModLoader.addName(BIron, "Blackened Iron"); ModLoader.addRecipe(new ItemStack(BIron, 2), new Object[] { "^^^", " # ", " @ ", '^', Bdust, '#', MIron, '@', Item.bucketWater }); BSword.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/Blackened Sword.png"); ModLoader.addName(BSword, "Blackened Sword"); ModLoader.addRecipe(new ItemStack(BSword, 1), new Object[] { " * ", " * ", " $ ", '*', BIron, '$', Item.stick }); BPick.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/BlackenedPickaxe.png"); ModLoader.addName(BPick, "Blackened Pickaxe"); ModLoader.addRecipe(new ItemStack(BPick, 1), new Object[] { "***", " $ ", " $ ", '*', BIron, '$', Item.stick }); BAxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/BlackenedAxe.png"); ModLoader.addName(BAxe, "Blackened Axe"); ModLoader.addRecipe(new ItemStack(BAxe, 1), new Object[] { "** ", "*$ ", " $ ", '*', BIron, '$', Item.stick }); BSpade.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/BlackenedShovel.png"); ModLoader.addName(BSpade, "Blackened Shovel"); ModLoader.addRecipe(new ItemStack(BSpade, 1), new Object[] { " * ", " $ ", " $ ", '*', BIron, '$', Item.stick }); BHoe.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/BlackenedHoe.png"); ModLoader.addName(BHoe, "Blackened Hoe"); ModLoader.addRecipe(new ItemStack(BHoe, 1), new Object[] { "** ", " $ ", " $ ", '*', BIron, '$', Item.stick }); ModLoader.registerBlock(Bore); Bore.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/Ores/Bore.png"); ModLoader.addName(Bore, "Blation Ore"); Bdust.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/bsdust.png"); ModLoader.addName(Bdust, "Blation Dust"); ModLoader.addArmor("BLACKENED"); } public void generateSurface(World world, Random random, int chunkX, int chunkZ) { randomGenerator = random; for (int i = 0; i < 25; i++) { int randPosX = chunkX + randomGenerator.nextInt(16); int randPosY = random.nextInt(80); int randPosZ = chunkZ + randomGenerator.nextInt(16); (new WorldGenMinable(Bore.blockID, 20)).generate(world, random, randPosX, randPosY, randPosZ); } } }
Pretty sure this should work, but I'm not entirely sure.
if ((mc.thePlayer.getItemInUse() != null) && mc.thePlayer.getItemInUse().itemID == (BPick.shiftedIndex | BSword.shiftedIndex | BAxe.shiftedIndex | BHoe.shiftedIndex | BSpade.shiftedIndex))
mc.thePlayer.setFire(3);
is not working when I swing the right item it dosn't set fire to the player
why is f1 never larger?
nextFloat generates a number between 0.1 and 1.0
The fire is still not working any ideas why???
would it have anything to do with the fact that this is the only class where the items are, that they don't have their own class????