Vswe's Summer Courses | You're not logged in. Sign up or log in | Server time: | Donate
One can now see other persons' badge hunts. Simply head over to their profiles to access them.

Go back to course page

Forging a Minecraft mod

Basic Minecraft modding with Minecraft Forge

Lecture #2 items part 1 advanced help

  • 2013-08-05 06:15:05
    In the lecture, I watched on how to create a wand that can make mobs fly in the air. I have successfully made the wand which does that. But I want to make another wand which will knock back the entity target (mob/player) away from the player using the code

    public boolean func_111207_a(ItemStack itemstack, EntityPlayer player, EntityLivingBase target) {
        if (!target.worldObj.isRemote) {
        target.knockBack(par1Entity, par2, par3, par5);    
    }
        
        return false;
    }

    par1entity would be the target, so the mob, but I need help with the other parameters because right now if I change them to a negative the mobs will be constantly pulled south even if the player is facing another direction. Also if the parameters were positive they will be knock backed constantly north. But one last thing they are not knock backed that far, only like 3-5 blocks.

    So if anyone could help me to make this knockback wand I would really appreciate it, thanks,

    EthanJY
  • 2013-08-05 09:08:47
    try this :

    public boolean func_111207_a(ItemStack itemstack, EntityPlayer player, EntityLivingBase target) {
        if(!target.worldObj.isRemote){
            target.motionX = (target.posX - player.posX) * 2;
            target.motionZ = (target.posZ - player.posZ) * 2;
        }
            
        return false;
    }

    its the same code for the charged wand for his lecture except without some parts.
  • 2013-08-05 09:53:42
    Thanks I really Appreciate the help, it works fine and just how I wanted to, thanks again for the help :D
  • Log in or sign up to reply to this thread