I want to be able to create new tools and weapons(using only the vanilla Materials(wood, stone, gold, iron, emerald)), but I get as far as having all of the abilities I want these items to have, except for the enchantments I want them to have access to.
When I was extending from ItemTool, they had access to all of the standard tool enchants, but when I have them extending from Item(and adding in all of the extra code that would have been otherwise already taken care of if I were still extending from ItemTool), they can only be enchanted with Unbreaking(I, II, III).
How do I specify which enchantments I want each item to have? (Ex: Only Unbreaking, sharpness, and efficiency.)
Now, I could also extend them from ItemSword to have access to those enchantments, but I want them to do more than just be a new sword type.
Extend from itemsword and change the code.
Or search a tutorial about defining enchantments. Don't know how complicate that is.
The enchantments are based on whether it extends ItemSword, ItemBow, ItemArmor, or ItemTool. I'd have to make it check for an additional tool type and create the list of enchantments allowed, but I don't know where to do that or if I CAN do it without editing base/forge classes.
Alternatively, I may just settle for trying to get it to work by extending from ItemSword, but I may have problems with that because I may not be able to change how the new tool handles breaking the materials I'm trying to design it to harvest.
I haven't yet found any tutorials on adding enchantments to new tool types. In fact, I have found no less than two other topics related to my issue that remain unresolved after MONTHS.
I may just have to make an API for custom tool types. (What it can harvest, the harvest speed, the enchantments, the right-click functionality(think hoe/sword), and anything else like that I may find.)
Alternatively, I may just settle for trying to get it to work by extending from ItemSword, but I may have problems with that because I may not be able to change how the new tool handles breaking the materials I'm trying to design it to harvest.
What are you trying to get it to do? Chances are that if you could get it to function in a class that doesn't extend ItemSword, you could get it to work by overriding a method with a class that does.
What are you trying to get it to do? Chances are that if you could get it to function in a class that doesn't extend ItemSword, you could get it to work by overriding a method with a class that does.
Well, I want to do a multitude of things(about 5), but they mainly boil down to giving tools sword(or bow) enchantments.
I tried rewriting it to extend ItemSword and still harvest the blocks I want it to block, but it doesn't break any block.(...at least it has sword enchants now)
Its almost as if that item is in adventure mode. It doesn't even make the 'you are smacking dirt' noise.
I'm at a loss as to why, though.
If I go back to extending Item and copy-pasting the appropriate ItemTool and ItemSword code, it only gets Unbreaking enchantments, but it can break blocks..
Not breaking blocks isn't something inherent to the ItemSword class, so that's still a viable option, as long as you fix the problem. What's in your class? Could you post that and the place where you instantiate your item?
Not breaking blocks isn't something inherent to the ItemSword class, so that's still a viable option, as long as you fix the problem. What's in your class? Could you post that and the place where you instantiate your item?
//Base class things:
public static Item woodOmniBlade;//and the other materials too
//in Load:
woodOmniBlade = new OmniBlade(3438, EnumToolMaterial.WOOD).setUnlocalizedName("OmniBladeWood");//and the other mats
LanguageRegistry.addName(woodOmniBlade, "Wood OmniBlade");//ditto
//Item class thing: (texture loading)
this.itemIcon = reg.registerIcon("OmniBladeWood");//same for the other materials
//My class:
package OmniTools;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.world.World;
import com.google.common.collect.Multimap;
import cpw.mods.fml.relauncher.Side;
public class OmniBlade extends ItemSword
{
public float efficiencyOnProperMaterial = 4.0F;
public static final Block[] blocksEffectiveAgainst = new Block[] {Block.planks, Block.bookShelf, Block.wood, Block.chest, Block.stoneDoubleSlab, Block.stoneSingleSlab, Block.pumpkin, Block.pumpkinLantern};
public OmniBlade(int par1, EnumToolMaterial par2EnumToolMaterial)
{
super(par1, par2EnumToolMaterial);
this.efficiencyOnProperMaterial = par2EnumToolMaterial.getEfficiencyOnProperMaterial();
}
public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLivingBase par7EntityLivingBase)
{
if ((double)Block.blocksList[par3].getBlockHardness(par2World, par4, par5, par6) != 0.0D)
{
par1ItemStack.damageItem(1, par7EntityLivingBase);
}
return true;
}
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
{
for (int i = 0; i < this.blocksEffectiveAgainst.length; ++i)
{
if (par2Block.blockID == Block.web.blockID)
{
return 15.0F;
}
else if (this.blocksEffectiveAgainst[i] == par2Block)
{
return this.efficiencyOnProperMaterial;
}
}
Material material = par2Block.blockMaterial;
return material != Material.plants && material != Material.vine && material != Material.coral && material != Material.leaves && material != Material.pumpkin ? 1.0F : 1.5F;
}
}
Just to be sure, you aren't in creative mode, are you? Swords won't break stuff in creative, allowing players to use their offensive properties without damaging the environment.
Just to be sure, you aren't in creative mode, are you? Swords won't break stuff in creative, allowing players to use their offensive properties without damaging the environment.
Its... its been a while since I visited creative and I remember being able to break blocks still...
But yes... Thanks. That was it.
I feel so stupid. I avoided checking that the last THREE times that I rewrote it because I remembered it working all those months ago.
SonofaCHICKEN!To anyone else: even though it didn't exactly answer my question, my main issue was solved.
I am now gonna report it as 'solved' and ask for it to be locked.
When I was extending from ItemTool, they had access to all of the standard tool enchants, but when I have them extending from Item(and adding in all of the extra code that would have been otherwise already taken care of if I were still extending from ItemTool), they can only be enchanted with Unbreaking(I, II, III).
How do I specify which enchantments I want each item to have? (Ex: Only Unbreaking, sharpness, and efficiency.)
Now, I could also extend them from ItemSword to have access to those enchantments, but I want them to do more than just be a new sword type.
Or search a tutorial about defining enchantments. Don't know how complicate that is.
The enchantments are based on whether it extends ItemSword, ItemBow, ItemArmor, or ItemTool. I'd have to make it check for an additional tool type and create the list of enchantments allowed, but I don't know where to do that or if I CAN do it without editing base/forge classes.
Alternatively, I may just settle for trying to get it to work by extending from ItemSword, but I may have problems with that because I may not be able to change how the new tool handles breaking the materials I'm trying to design it to harvest.
I haven't yet found any tutorials on adding enchantments to new tool types. In fact, I have found no less than two other topics related to my issue that remain unresolved after MONTHS.
I may just have to make an API for custom tool types. (What it can harvest, the harvest speed, the enchantments, the right-click functionality(think hoe/sword), and anything else like that I may find.)
No. A Tool with Sword enchantments.
It's not as specific.
What are you trying to get it to do? Chances are that if you could get it to function in a class that doesn't extend ItemSword, you could get it to work by overriding a method with a class that does.
Well, I want to do a multitude of things(about 5), but they mainly boil down to giving tools sword(or bow) enchantments.
I tried rewriting it to extend ItemSword and still harvest the blocks I want it to block, but it doesn't break any block.(...at least it has sword enchants now)
Its almost as if that item is in adventure mode. It doesn't even make the 'you are smacking dirt' noise.
I'm at a loss as to why, though.
If I go back to extending Item and copy-pasting the appropriate ItemTool and ItemSword code, it only gets Unbreaking enchantments, but it can break blocks..
Its... its been a while since I visited creative and I remember being able to break blocks still...
But yes... Thanks. That was it.
I feel so stupid. I avoided checking that the last THREE times that I rewrote it because I remembered it working all those months ago.
SonofaCHICKEN!To anyone else: even though it didn't exactly answer my question, my main issue was solved.
I am now gonna report it as 'solved' and ask for it to be locked.