Knockback Player Snowball

CanaryMod related discussions

Knockback Player Snowball

Postby Rash_SR » Tue Jan 10, 2017 11:30 pm

Hello Guys!

I wanted to code a simple Plugin in wich i want that player can hit other players with snowballs and give them knockback.
I looked in the CanaryDoc and found the function "knockBack(double xForce, double zForce)" in the net.canarymod.api.entity.living.LivingBase. So i write in my plugin(only the important code here)

@Command(aliases = { "knockback" },
description = "snowball plugin",
permissions = { "*" },
toolTip = "/knockback")
public void snowballCommand(MessageReceiver caller, String[] args) {
if (caller instanceof Player) {

Player player = (Player)caller;
double xForce = Double.parseDouble(args[1]);
double zForce = Double.parseDouble(args[2]);
player.chat("x value is " + xForce);
player.chat("z value is " + zForce);

player.knockBack(xForce, zForce);
}
}

so i type in the chatbox "/knockback 4 4" an tried with many other doubles but nothing happend(only the .chat() works and show the xForce and zForce which i type in the chat).. then i try to spawn a cow and give the mob knockback with a command and this worked. the cow get knockback!

now my Question is: Is there somethin wrong? or is there another function in the Documentation(i don't found one)wich can get the Player knockback? Have someone an idea?

I hope someone can help me! Thank you.
Rash_SR
 
Posts: 11
Joined: Mon Jan 18, 2016 5:58 pm

Return to Discussions

Who is online

Users browsing this forum: No registered users and 10 guests

cron