Jump to content

Recommended Posts

Posted

Hello,

Like the title says, I want to set a swords damage vs entity to a value in an NBT tag.

 

I have a sword with a container item where you can insert a specific item in a slot and based on that item I am writing NBT data to the sword item.I have searched in the ItemSword and Item class but I could not find a functions that allows this.All the functions that deal with damage are called once when the game is loaded.

 

Also I have anther questions that is related to this one.I want to make a pickaxe that changes the efficiencyOnProperMaterial field based on NBT data like the sword, but I could not find how to do this either.

 

I plan to make a hole set of tools that have a container and that change certain aspects of them like damage vs entity, efficiency and total damage(which I know how to set because there is a function for that in the Item class).

 

Why aren't there such functions or the damage vs entity and efficiency in the Item class or ItemTool class or am I just missing them?

 

Thank you for your help.

 

EDIT: Is it also possible to add an enchantment effect based on NBT?

 

EDIT 2: Sorry for so many edits, but I just want to ask you your opinion on this piece of code:

	@Override
public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer player)
{
	if (this.getDamage(itemstack) >= 498 && player.capabilities.isCreativeMode == false)
		return true;
	return false;
}

Currently I use this method on my custom pickaxe.My pickaxe is unbreakable and uses a custom fuel I made to recharge it's durability.My question is:

 

Is there a better way to do it so the tool is indestructible and only works if it is recharged with my custom fuel?

 

 

Sorry for all these questions, haven't posted on this forum for a while and now I remember all the problems I wanted to ask here but found a solution myself for them :)

Posted

I looked at Modular Powersuits source code and I've created an hitEntity function that works but I am not sure if I am doing things properly.

 

	@Override
    public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase)
    {
    	if (this.getDamage(par1ItemStack) >= 998)
    		return false;
    	float damage = weaponDamage;
    	if(par1ItemStack.hasTagCompound())
    	{
    		System.out.println("works");
		if(par1ItemStack.getTagCompound().getInteger("speed")==1)
		{
			System.out.println("works1");
			damage+=2.0F;
		}
    	}
    	DamageSource damagesource = DamageSource.causePlayerDamage((EntityPlayer)par3EntityLivingBase);
    	par2EntityLivingBase.attackEntityFrom(damagesource, damage);
    	par1ItemStack.damageItem(1, par3EntityLivingBase);
    	return true;
    }

Posted

You can see damage change in ItemSword, and harvest in ItemTool, though ForgeHooks contains a hook in case you need it.

 

I am quite sure you can add enchantment at any time, I'd look at ItemEnchantedBook if I were you.

 

This.

player.capabilities.isCreativeMode == false

is wrong.

Fix, please  :-\

Posted

You can see damage change in ItemSword, and harvest in ItemTool, though ForgeHooks contains a hook in case you need it.

 

I am quite sure you can add enchantment at any time, I'd look at ItemEnchantedBook if I were you.

 

This.

player.capabilities.isCreativeMode == false

is wrong.

Fix, please  :-\

 

Can you please be more specific?I have searched the ItemSword class and ItemTool class for functions that allow what I am saying, only private fields that are used only when the constructor is called.

 

Also why is

player.capabilities.isCreativeMode == false

wrong?

It works, when the player is in creative mode it still allows them to destroy the blocks even when the durability is bigger than 998.Should I not check for it because creative mode handles things differently?I will try and see.

Posted

So you found weaponDamage in ItemSword, but didn't search where it is used in the class ?  ???

You couldn't found the "Weapon modifier" AttributeModifier ?

You found efficiencyOnProperMaterial in ItemTool, but couldn't find getStrVsBlock method ?

 

It should be !player.capabilities.isCreativeMode , obviously...where did you learn to code ?

 

 

Posted

So you found weaponDamage in ItemSword, but didn't search where it is used in the class ?  ???

You couldn't found the "Weapon modifier" AttributeModifier ?

You found efficiencyOnProperMaterial in ItemTool, but couldn't find getStrVsBlock method ?

 

It should be !player.capabilities.isCreativeMode , obviously...where did you learn to code ?

 

The public Multimap func_111205_h() uses the variable but I tried overwriting that function and I used a custom variable but it did not work, that's why I am asking on this forum.I already tried everything that I can think of and the only thing that works is how Modular Powersuits does it.

 

I knew the getStrVsBlock function but I didn't want to use it because if I make a custom tool that extends the ToolPickaxe class but is classified as a shovel with MinecraftForge.setToolClass(this, "shovel", 3);

then the getStrVsBlock function has to be heavily modified and I didn't want to do that.Anyways, I may try that if that is the only solution.

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.