Java Reference
In-Depth Information
Let's make our own version. Create a new function in this plugin and name
it myFling . Copy the version from EZPlugin into the body of the function, and it
will look like this:
public static void myFling(LivingBase player,
LivingBase entity, double factor) {
double pitch = (player.getPitch() + 90.0F) * Math .PI / 180.0D;
double rot = (player.getRotation() + 90.0F) * Math .PI / 180.0D;
double x = Math .sin(pitch) * Math .cos(rot);
double z = Math .sin(pitch) * Math .sin(rot);
double y = Math .cos(pitch);
entity.moveEntity(x * factor, y + 0.5, z * factor);
And change the 0.5 on the last line to some other number, say 1.5 .
Then change the call to myFling instead of fling :
Canary.getServer().addSynchronousTask( new CowTask(victim));
myFling(player, victim, 3);
Run to make sure it still works, and commit your changes:
$ git commit -a -m 'Moved vector calculation'
[play 411208c] Moved vector calculation
1 file changed, 9 insertions(+), 1 deletion(-)
Now with that safely in a snapshot in the play branch, let's go back and take
a look at the original:
$ git checkout master
Switched to branch 'master'
And now the version of on disk is the version in the master reality.
Take a look at it and see. One note of caution: Git changed the text file on
disk. The version in your editor's buffer might be the old one. Most editors
are savvy enough to realize when a file has changed out from under them,
but how that's handled is up to the editor.
Now back here in master , let's change the cow shooter to shoot creepers instead.
In both and , add the import for Creeper at the bottom
of the list of imports:
import; // Add this line
Search WWH ::

Custom Search