    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import java.awt.Component;
    006    import org.lwjgl.input.Mouse;
    007
    008    @SideOnly(Side.CLIENT)
    009    public class MouseHelper
    010    {
    011        private Component windowComponent;
    012
    013        /** Mouse delta X this frame */
    014        public int deltaX;
    015
    016        /** Mouse delta Y this frame */
    017        public int deltaY;
    018
    019        public MouseHelper(Component par1Component)
    020        {
    021            this.windowComponent = par1Component;
    022        }
    023
    024        /**
    025         * Grabs the mouse cursor it doesn't move and isn't seen.
    026         */
    027        public void grabMouseCursor()
    028        {
    029            Mouse.setGrabbed(true);
    030            this.deltaX = 0;
    031            this.deltaY = 0;
    032        }
    033
    034        /**
    035         * Ungrabs the mouse cursor so it can be moved and set it to the center of the screen
    036         */
    037        public void ungrabMouseCursor()
    038        {
    039            Mouse.setCursorPosition(this.windowComponent.getWidth() / 2, this.windowComponent.getHeight() / 2);
    040            Mouse.setGrabbed(false);
    041        }
    042
    043        public void mouseXYChange()
    044        {
    045            this.deltaX = Mouse.getDX();
    046            this.deltaY = Mouse.getDY();
    047        }
    048    }