var scriptName = "TPJesusBeta";
var scriptAuthor = "c@n-c,.,crn4m<ee & Survi_G";
var scriptVersion = 0.4;


 Math.radians = function(degrees) {
    return degrees * Math.PI / 180;
  };
  

  Math.degrees = function(radians) {
    return radians * 180 / Math.PI;
  };

function vClip(offset) {
    mc.thePlayer.setPosition(mc.thePlayer.posX, mc.thePlayer.posY + offset, mc.thePlayer.posZ);
}

function hClip(offset) {
    var playerYaw = Math.radians(mc.thePlayer.rotationYaw);
    mc.thePlayer.setPosition(mc.thePlayer.posX - (Math.sin(playerYaw) * offset), mc.thePlayer.posY, mc.thePlayer.posZ + (Math.cos(playerYaw) * offset));
}


function FlyModule() {

    this.getName = function() {
        return "MineplexJesus";
    };

    this.getDescription = function() {
        return "TP Jesus for Mineplex";
    };

    this.getCategory = function() {
        return "Movement";

    };
   
    this.onUpdate = function() {
        if (mc.thePlayer.isInLava() || mc.thePlayer.isInWater()) {
            mc.thePlayer.motionY = 0.2;
            vClip(0.1);
            hClip(0.2);
        }

        if (mc.thePlayer.isBlocking() && mc.thePlayer.isInWater() || mc.thePlayer.isInLava() ) {
            commandManager.executeCommand(".t MineplexJesus");
            mc.thePlayer.motionY = 0.2;
        }
   
    };

    this.onEnable = function() {
        chat.print("§4§lIf you reach the end of the water, Block with your sword!");
chat.print("§4The Jesus is highly unfinished and probably buggy.");
chat.print("§lif you get flagged while NOT being at the end of a block, contact me.");
    };
   
    this.onDisable = function() {
        mc.timer.timerSpeed = 1.0;
        mc.thePlayer.motionY = 0.0;

    };

}

var flyModule = new FlyModule();
var flyModuleClient;

function onEnable() {
    flyModuleClient = moduleManager.registerModule(flyModule);
}

function onDisable() {
    moduleManager.unregisterModule(flyModuleClient);
}