    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 final Component windowComponent;
    012        private final GameSettings field_85184_d;
    013
    014        /** Mouse delta X this frame */
    015        public int deltaX;
    016
    017        /** Mouse delta Y this frame */
    018        public int deltaY;
    019
    020        public MouseHelper(Component par1Component, GameSettings par2GameSettings)
    021        {
    022            this.windowComponent = par1Component;
    023            this.field_85184_d = par2GameSettings;
    024        }
    025
    026        /**
    027         * Grabs the mouse cursor it doesn't move and isn't seen.
    028         */
    029        public void grabMouseCursor()
    030        {
    031            Mouse.setGrabbed(true);
    032            this.deltaX = 0;
    033            this.deltaY = 0;
    034        }
    035
    036        /**
    037         * Ungrabs the mouse cursor so it can be moved and set it to the center of the screen
    038         */
    039        public void ungrabMouseCursor()
    040        {
    041            Mouse.setCursorPosition(this.windowComponent.getWidth() / 2, this.windowComponent.getHeight() / 2);
    042            Mouse.setGrabbed(false);
    043        }
    044
    045        public void mouseXYChange()
    046        {
    047            this.deltaX = Mouse.getDX();
    048            this.deltaY = Mouse.getDY();
    049        }
    050    }