Hey everyone. Im new to modding and i have all of my base stuff but i want to have a sword that when i hit a enemy it lights them on fire. I need help ive looked all through the code and cant find a way to make it so.
Thanks,
Legitassassin12
I'm not good at coding, either. But my guess is to look up the enchantment for the "fire aspect" and have the code applied immediatly to the weapon.
Edit: Do you only want mobs to burn? Or everything to burn? If you just want mobs to burn then try what I said above, but other than that idk xD
I want it to only burn mobs. I've looked up fire aspect and it doesnt look like i could just do that to the sword i want the fire effect to be on. But ill look again but if anyone else has a idea then please post it. Thanks.
ok so just make a (whatever my swords name is).class and then in there paste that code in? that sounds easy enought. thanks
Well obviously you need to change your mod_***.class so that it knows the item is using that class file for your sword, You will need some other bits and bobs in the your swordname.class, as well. But other than that, yeah, that's all you need to do.
Just checking, it isa custom sword you're making, right? you're not putting that as an extra effect on a vanilla sword?
Well obviously you need to change your mod_***.class so that it knows the item is using that class file for your sword, You will need some other bits and bobs in the your swordname.class, as well. But other than that, yeah, that's all you need to do.
Just checking, it isa custom sword you're making, right? you're not putting that as an extra effect on a vanilla sword?
I tried this and it doesn't seem to work... I put it in my "sword.java" class in my public class and it just doesn't light them on fire... Any suggestions? What else do I need to create (I already imported the package, so that isn't the issue)? Thanks!
Rollback Post to RevisionRollBack
"Those who cannot change their minds cannot change anything"
"If you want something done right, do it yourself"
I tried this and it doesn't seem to work... I put it in my "sword.java" class in my public class and it just doesn't light them on fire... Any suggestions? What else do I need to create (I already imported the package, so that isn't the issue)? Thanks!
Can you show us your code? It'll be easier to see your problem then.
Sure, here it is (I am in a class and we just did things like "testItem", so... yeah, I know what to change when I want to rename the file, and please mind the screwing around of the numbers )
public class testBlock extends Block
{
public testBlock()
{
super(Material.rock);
setBlockName("Mod_testBlock");
setBlockTextureName("mod:mod");
setCreativeTab(CreativeTabs.tabBlock);
this.setHardness(0.1F);
this.setLightLevel(16F);
this.setResistance(-15000.0F);
//this.setLightOpacity(0.0F);
}
public int quantityDropped(Random p_149745_1_)
{
return 7;
}
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
{
return mod.testItem;
}
}
@Mod(modid = mod.MODID, version = mod.VERSION)
public class mod
{
public static final String MODID = "mod";
public static final String VERSION = "v1.0";
public static code.mod.testBlock testBlock;
public static Item testItem;
public static final Item.ToolMaterial CustomMat =
EnumHelper.addToolMaterial("SwordMat", 10, 999999999, 1500.0F, 999999999.0F, 127);
@EventHandler
public void init(FMLInitializationEvent event)
{
testItem = new testItem(CustomMat);
testBlock = new testBlock();
public class testItem extends Item
{
public testItem()
{
super();
setUnlocalizedName("testItem");
setCreativeTab(CreativeTabs.tabMisc);
setTextureName("dynamiteStick:mod");
}
}
Rollback Post to RevisionRollBack
"Those who cannot change their minds cannot change anything"
"If you want something done right, do it yourself"
Oh gosh... I've been working on this all morning, some things might me changed (or not agree)... The errors have been fixed... Just pretend they don't exist...
Rollback Post to RevisionRollBack
"Those who cannot change their minds cannot change anything"
"If you want something done right, do it yourself"
Oh gosh... I've been working on this all morning, some things might me changed (or not agree)... The errors have been fixed... Just pretend they don't exist...
That should make it light entities on fire when hit
Thanks,
Legitassassin12
Edit: Do you only want mobs to burn? Or everything to burn? If you just want mobs to burn then try what I said above, but other than that idk xD
I want it to only burn mobs. I've looked up fire aspect and it doesnt look like i could just do that to the sword i want the fire effect to be on. But ill look again but if anyone else has a idea then please post it. Thanks.
i happen to be using this for a mod im currently developing, so your in luck!
you can change the "10" value to alter the time the mob is on fire
I sent another quote to u but just in case, how do i add it specificly to a sword? When i try something i think will work it says a error
ok so just make a (whatever my swords name is).class and then in there paste that code in? that sounds easy enought. thanks
Well obviously you need to change your mod_***.class so that it knows the item is using that class file for your sword, You will need some other bits and bobs in the your swordname.class, as well. But other than that, yeah, that's all you need to do.
Just checking, it is a custom sword you're making, right? you're not putting that as an extra effect on a vanilla sword?
Ya thanks i found out.
"If you want something done right, do it yourself"
Can you show us your code? It'll be easier to see your problem then.
教えて教えてよその仕組みを。
testBlock.java:
package code.mod;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
public class testBlock extends Block
{
public testBlock()
{
super(Material.rock);
setBlockName("Mod_testBlock");
setBlockTextureName("mod:mod");
setCreativeTab(CreativeTabs.tabBlock);
this.setHardness(0.1F);
this.setLightLevel(16F);
this.setResistance(-15000.0F);
//this.setLightOpacity(0.0F);
}
public int quantityDropped(Random p_149745_1_)
{
return 7;
}
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
{
return mod.testItem;
}
}
mod.java:
package code.mod;
import com.jcraft.jorbis.Block;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
@Mod(modid = mod.MODID, version = mod.VERSION)
public class mod
{
public static final String MODID = "mod";
public static final String VERSION = "v1.0";
public static code.mod.testBlock testBlock;
public static Item testItem;
public static final Item.ToolMaterial CustomMat =
EnumHelper.addToolMaterial("SwordMat", 10, 999999999, 1500.0F, 999999999.0F, 127);
@EventHandler
public void init(FMLInitializationEvent event)
{
testItem = new testItem(CustomMat);
testBlock = new testBlock();
GameRegistry.registerItem(testItem, "testItem");
GameRegistry.registerBlock(testBlock, "testBLock");
GameRegistry.addRecipe(new ItemStack(Items.dye, 2, 15), new Object[]
{
"AB ",
"AAC",
"A ",
'A', Items.cookie, 'B', Blocks.dirt, 'C', new ItemStack(Items.dye, 1, 1)
});
GameRegistry.addRecipe(new ItemStack(Blocks.diamond_block, 64), new Object[]
{
"AA",
"AA",
'A', Blocks.dirt
});
GameRegistry.addShapelessRecipe(new ItemStack(Blocks.cobblestone, 1), new Object[]
{
Blocks.gravel
});
GameRegistry.addRecipe(new ItemStack(Blocks.tnt), new Object[]
{
"AAA",
"AAA",
"AAA",
'A', testBlock
});
}
}
Like I said, mind the screwing around... And the formatting, I can't sit here and "<TAB>" it out... Thanks!!!
"If you want something done right, do it yourself"
And what about your testItem file?
教えて教えてよその仕組みを。
package code.mod;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSword;
public class testItem extends Item
{
public testItem()
{
super();
setUnlocalizedName("testItem");
setCreativeTab(CreativeTabs.tabMisc);
setTextureName("dynamiteStick:mod");
}
}
"If you want something done right, do it yourself"
"If you want something done right, do it yourself"
That should make it light entities on fire when hit
教えて教えてよその仕組みを。
package com.msm.moreswordsmod;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.EntityLiving;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
public class ItemFSword extends ItemSword {
public ItemFSword(ToolMaterial material) {
super(material);
}
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
{
par1ItemStack.damageItem(1, par3EntityLiving);
par2EntityLiving.setFire(10);
return true;
}
}
I do not understand why this is not working for me
This thread is not for 1.12.2 so that could be why.