This shouldn't be too hard, but Im very very new to Java scripting. Ive basically been self teaching by observing what is happening in my mod and I think I have almost everything done. My last issue is that I want the game to display a certain image based on what material the weapon in my mod is made of. My mod currently only has a BattleAxe as the only difference, and I would like it to display the image axeWood, axeStone, axeIron etc. depending on what it is made of. I am hoping to use SOMETHING like this...
String material = x
if
par2EnumToolMaterial = EMERALD
then
return x = Diamond
elseif
par2EnumToolMaterial = IRON
then
return x = Iron
etc.
Obviously I have no idea at all what I'm doing... or if this is even possible. Help from any good coder would be greatly appreciated to help me clean up my code properly. Thank you in advance.
Rollback Post to RevisionRollBack
Check out the best mods ever HERE!
CraftMoreTools and CraftMoreBuildings!
Reading your code, I feel this is possible, but here is an idea of what you could do:
String material = "x"
if par2EnumToolMaterial = EMERALD{
material = "Diamond"
elseif par2EnumToolMaterial = IRON{
material = "Iron"
}
//Do the other tool materials here
public class mod_CraftMore extends BaseMod
{
public class ItemBAxe extends Item
{
private int weaponDamage;
private final EnumToolMaterial toolMaterial;
public int func_82803_g()
{
return this.toolMaterial.getDamageVsEntity();
}
/**
* Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if
* sword
*/
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
{
if (par2Block.blockMaterial == Material.wood)
{
return 15.0F;
}
else
{
return 1.0F;
}
}
/**
* Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
* the damage on the stack.
*/
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
{
par1ItemStack.damageItem(1, par3EntityLiving);
return true;
}
public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLiving par7EntityLiving)
{
if ((double)Block.blocksList[par3].getBlockHardness(par2World, par4, par5, par6) != 0.0D)
{
par1ItemStack.damageItem(2, par7EntityLiving);
}
return true;
}
/**
* Returns the damage against a given entity.
*/
public int getDamageVsEntity(Entity par1Entity)
{
return this.weaponDamage;
}
/**
* Returns True is the item is renderer in full 3D when hold.
*/
public boolean isFull3D()
{
return true;
}
/**
* returns the action that specifies what animation to play when the items is being used
*/
public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
return EnumAction.block;
}
/**
* How long it takes to use or consume an item
*/
public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
return 72000;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
}
/**
* Returns if the item (tool) can harvest results from the block type.
*/
public boolean canHarvestBlock(Block par1Block)
{
return par1Block.blockID == Block.web.blockID;
}
/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return this.toolMaterial.getEnchantability();
}
/**
* Return the name for this tool's material.
*/
public String getToolMaterialName()
{
return this.toolMaterial.toString();
}
/**
* Return whether this item is repairable in an anvil.
*/
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
{
return this.toolMaterial.getToolCraftingMaterial() == par2ItemStack.itemID ? true : super.getIsRepairable(par1ItemStack, par2ItemStack);
}
}
public void load()
{
}
public String getVersion() {
return "0.1";
}
}
That is my whole code. Any help at all would be great... I recompiled without any issues but there is no trace at all of my Battleaxe. Obviously I took the Sword code and just modified it to be stronger and better against wood...
public class mod_CraftMore extends BaseMod
{
public class ItemBAxe extends Item
{
private int weaponDamage;
private final EnumToolMaterial toolMaterial;
public int func_82803_g()
{
return this.toolMaterial.getDamageVsEntity();
}
/**
* Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if
* sword
*/
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
{
if (par2Block.blockMaterial == Material.wood)
{
return 15.0F;
}
else
{
return 1.0F;
}
}
/**
* Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
* the damage on the stack.
*/
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
{
par1ItemStack.damageItem(1, par3EntityLiving);
return true;
}
public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLiving par7EntityLiving)
{
if ((double)Block.blocksList[par3].getBlockHardness(par2World, par4, par5, par6) != 0.0D)
{
par1ItemStack.damageItem(2, par7EntityLiving);
}
return true;
}
/**
* Returns the damage against a given entity.
*/
public int getDamageVsEntity(Entity par1Entity)
{
return this.weaponDamage;
}
/**
* Returns True is the item is renderer in full 3D when hold.
*/
public boolean isFull3D()
{
return true;
}
/**
* returns the action that specifies what animation to play when the items is being used
*/
public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
return EnumAction.block;
}
/**
* How long it takes to use or consume an item
*/
public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
return 72000;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
}
/**
* Returns if the item (tool) can harvest results from the block type.
*/
public boolean canHarvestBlock(Block par1Block)
{
return par1Block.blockID == Block.web.blockID;
}
/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return this.toolMaterial.getEnchantability();
}
/**
* Return the name for this tool's material.
*/
public String getToolMaterialName()
{
return this.toolMaterial.toString();
}
/**
* Return whether this item is repairable in an anvil.
*/
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
{
return this.toolMaterial.getToolCraftingMaterial() == par2ItemStack.itemID ? true : super.getIsRepairable(par1ItemStack, par2ItemStack);
}
}
public void load()
{
}
public String getVersion() {
return "0.1";
}
}
That is my whole code. Any help at all would be great... I recompiled without any issues but there is no trace at all of my Battleaxe. Obviously I took the Sword code and just modified it to be stronger and better against wood...
Ya o.o I have no idea at all and I cant really find anywhere to help. Do you know how I can get help with that? xD Ive literally never done this before.
Rollback Post to RevisionRollBack
Check out the best mods ever HERE!
CraftMoreTools and CraftMoreBuildings!
Ya o.o I have no idea at all and I cant really find anywhere to help. Do you know how I can get help with that? xD Ive literally never done this before.
Thanks I'll definitely look through those, although I'm not really seeing how to make a new weapon. Im hoping it will be similar to tools... Almost everything I can find are either setting up MCP or creating new blocks... This is quite a bit more difficult than I expected.
Rollback Post to RevisionRollBack
Check out the best mods ever HERE!
CraftMoreTools and CraftMoreBuildings!
if
par2EnumToolMaterial = EMERALD
then
return x = Diamond
elseif
par2EnumToolMaterial = IRON
then
return x = Iron
etc.
BAxe.IconIndex = ModLoader.addOverride("textures/items/axe"+x+".png");
Obviously I have no idea at all what I'm doing... or if this is even possible. Help from any good coder would be greatly appreciated to help me clean up my code properly. Thank you in advance.
CraftMoreTools and CraftMoreBuildings!
Then in the constructor:
import java.util.Random;
public class mod_CraftMore extends BaseMod
{
public class ItemBAxe extends Item
{
private int weaponDamage;
private final EnumToolMaterial toolMaterial;
public ItemBAxe(int par1, EnumToolMaterial par2EnumToolMaterial)
{
super(par1);
this.toolMaterial = par2EnumToolMaterial;
this.maxStackSize = 1;
this.setMaxDamage(par2EnumToolMaterial.getMaxUses());
this.setCreativeTab(CreativeTabs.tabCombat);
this.weaponDamage = + par2EnumToolMaterial.getDamageVsEntity();
}
public int func_82803_g()
{
return this.toolMaterial.getDamageVsEntity();
}
/**
* Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if
* sword
*/
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
{
if (par2Block.blockMaterial == Material.wood)
{
return 15.0F;
}
else
{
return 1.0F;
}
}
/**
* Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
* the damage on the stack.
*/
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
{
par1ItemStack.damageItem(1, par3EntityLiving);
return true;
}
public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLiving par7EntityLiving)
{
if ((double)Block.blocksList[par3].getBlockHardness(par2World, par4, par5, par6) != 0.0D)
{
par1ItemStack.damageItem(2, par7EntityLiving);
}
return true;
}
/**
* Returns the damage against a given entity.
*/
public int getDamageVsEntity(Entity par1Entity)
{
return this.weaponDamage;
}
/**
* Returns True is the item is renderer in full 3D when hold.
*/
public boolean isFull3D()
{
return true;
}
/**
* returns the action that specifies what animation to play when the items is being used
*/
public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
return EnumAction.block;
}
/**
* How long it takes to use or consume an item
*/
public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
return 72000;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
}
/**
* Returns if the item (tool) can harvest results from the block type.
*/
public boolean canHarvestBlock(Block par1Block)
{
return par1Block.blockID == Block.web.blockID;
}
/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return this.toolMaterial.getEnchantability();
}
/**
* Return the name for this tool's material.
*/
public String getToolMaterialName()
{
return this.toolMaterial.toString();
}
/**
* Return whether this item is repairable in an anvil.
*/
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
{
return this.toolMaterial.getToolCraftingMaterial() == par2ItemStack.itemID ? true : super.getIsRepairable(par1ItemStack, par2ItemStack);
}
}
public void load()
{
}
public String getVersion() {
return "0.1";
}
}
That is my whole code. Any help at all would be great... I recompiled without any issues but there is no trace at all of my Battleaxe. Obviously I took the Sword code and just modified it to be stronger and better against wood...
CraftMoreTools and CraftMoreBuildings!
You might want to learn how to make a mod morely.
CraftMoreTools and CraftMoreBuildings!
www.youtube.com/
CraftMoreTools and CraftMoreBuildings!
CraftMoreTools and CraftMoreBuildings!