    001    package net.minecraft.util;
    002
    003    import cpw.mods.fml.relauncher.Side;
    004    import cpw.mods.fml.relauncher.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            int var1 = this.windowComponent.getWidth();
    043            int var2 = this.windowComponent.getHeight();
    044
    045            if (this.windowComponent.getParent() != null)
    046            {
    047                var1 = this.windowComponent.getParent().getWidth();
    048                var2 = this.windowComponent.getParent().getHeight();
    049            }
    050
    051            Mouse.setCursorPosition(var1 / 2, var2 / 2);
    052            Mouse.setGrabbed(false);
    053        }
    054
    055        public void mouseXYChange()
    056        {
    057            this.deltaX = Mouse.getDX();
    058            this.deltaY = Mouse.getDY();
    059        }
    060    }