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