Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Minecraft mc = Minecraft.getMinecraft();
- private Random rand = new Random();
- private double yVal;
- private boolean airDamaged;
- private Timer startTime = new Timer();
- private Timer glideTime = new Timer();
- public boolean require_Air_Damage = true;
- public boolean motion_Glide = false;
- private double preX;
- private double preZ;
- public Glide() {
- super("fly", "Fly", 0xFFFF56A3, Category.MOVEMENT, true);
- }
- public void onEnable() {
- this.startTime.reset();
- if (this.mc.thePlayer.onGround) {
- this.airDamaged = false;
- damage();
- this.yVal = this.mc.thePlayer.posY;
- }
- if (!require_Air_Damage) {
- this.airDamaged = true;
- }
- EventManager.register(this);
- }
- public void onDisable() {
- EventManager.unregister(this);
- this.mc.thePlayer.motionY = -0.005D;
- }
- @EventTarget
- public void onPreUpdate(EventPreUpdate event) {
- if ((this.mc.thePlayer.hurtTime > 0) && (this.startTime.hasReached(1000L)))
- this.airDamaged = true;
- }
- @EventTarget
- public void onPreMovePlayer(EventPreMovePlayer event) {
- event.setY(motion_Glide ? -0.03126D : event.getY() * 1.0E-013D);
- double movementMultiplier = this.mc.thePlayer.capabilities.getFlySpeed() * 20.0D;
- if (this.mc.gameSettings.keyBindSneak.getIsKeyPressed())
- {
- if ((this.airDamaged) || (!BlockHelper.isOnFloor(-0.7D))) {
- event.setY(event.getY() - 0.28D * movementMultiplier);
- if (!this.mc.thePlayer.onGround) {
- this.mc.thePlayer.movementInput.sneak = false;
- }
- }
- }
- if ((this.mc.gameSettings.keyBindJump.getIsKeyPressed()) && (this.airDamaged) &&
- (this.mc.thePlayer.posY < this.yVal - 0.1D)) {
- event.setY(event.getY() + 0.28D * movementMultiplier);
- }
- this.mc.thePlayer.fallDistance = 0.0F;
- this.mc.thePlayer.onGround = true;
- }
- @EventTarget
- public void onPreMotion(EventPreMotionUpdates event) {
- this.preX = this.mc.thePlayer.posX;
- this.preZ = this.mc.thePlayer.posZ;
- if ((this.mc.thePlayer.motionX == 0.0D) && (this.mc.thePlayer.motionZ == 0.0D) && (!this.mc.thePlayer.onGround) && (this.mc.thePlayer.motionY < 0.0D) &&
- (this.glideTime.hasReached(1000L))) {
- this.mc.thePlayer.posX += (this.rand.nextGaussian() - 0.5D) * 0.1D;
- this.mc.thePlayer.posZ += (this.rand.nextGaussian() - 0.5D) * 0.1D;
- this.glideTime.reset();
- }
- }
- public static void damage() {
- double[] d = { 0.2D, 0.24D };
- for (int a = 0; a < 100; a++)
- for (int i = 0; i < d.length; i++)
- mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(mc.thePlayer.posX, mc.thePlayer.posY + d[i], mc.thePlayer.posZ, false));
- }
- @EventTarget
- public void onPostMotion(EventPostMotionUpdates event) {
- this.mc.thePlayer.posX = this.preX;
- this.mc.thePlayer.posZ = this.preZ;
- }
- @EventTarget(4)
- public void onSendPacket(EventSendPacket event) {
- if ((event.getPacket() instanceof C03PacketPlayer)) {
- C03PacketPlayer packet = (C03PacketPlayer)event.getPacket();
- packet.field_149474_g = false;
- if ((this.airDamaged) &&
- (BlockHelper.getBlock(packet.x, Math.ceil(packet.y - 2.0D), packet.z).getMaterial().blocksMovement())) {
- double y = Math.ceil(packet.y + 0.1D - 2.0D) + 2.0D;
- if (y < this.yVal)
- packet.y = y;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement