Posted July 22, 20169 yr Hello, I'm trying to make a custom material apply wither, and set the target on fire if the entity it hits is undead. However, it doesn't seem to apply this effect on hit. Here's my code: [spoiler=Sword Class] package com.t10a.minedran.item.weapons; import com.t10a.minedran.reference.Reference; import com.t10a.minedran.init.ModItems; import com.t10a.minedran.item.MaterialEffects; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EnumCreatureAttribute; import net.minecraft.init.MobEffects; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; public class ItemCustomSword extends ItemSword { public ItemCustomSword(ToolMaterial material) { super(material); setMaxStackSize(1); setCreativeTab(CreativeTabs.COMBAT); setUnlocalizedName(Reference.ItemBase.MODSWORD.getUnlocalizedName() + "_" + getToolMaterialName().toLowerCase()); setRegistryName(Reference.ItemBase.MODSWORD.getRegistryName() + "_" + getToolMaterialName().toLowerCase()); } public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker, ToolMaterial material) { MaterialEffects.effectsOnAttack(material, stack, target, attacker); stack.damageItem(1, attacker); return true; } } [spoiler=Material Effects Class] package com.t10a.minedran.item; import com.t10a.minedran.init.ModItems; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EnumCreatureAttribute; import net.minecraft.init.MobEffects; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.potion.PotionEffect; import net.minecraft.item.ItemStack; public abstract class MaterialEffects { public static void effectsOnAttack(final ToolMaterial material, final ItemStack stack, final EntityLivingBase target, final EntityLivingBase attacker) { if (material.equals(ModItems.TUTORIAL)) { if(target.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD) { target.addPotionEffect(new PotionEffect(MobEffects.WITHER, 60, 3)); target.setFire(10); } } } } Thanks if you can help. If I'm asking a whole bunch of questions, please don't get angry. I'm trying to learn.
July 22, 20169 yr Your hitEntity method doesn't override a super method, you can't just add random parameters to a method and expect it to be called. If you'd used the @Override annotation, you would have already known this was the problem. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
July 22, 20169 yr Author Oops. Silly me. Thanks If I'm asking a whole bunch of questions, please don't get angry. I'm trying to learn.
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.