Search in sources :

Example 71 with Minecraft

use of net.minecraft.client.Minecraft in project watson by totemo.

the class Chat method serverChat.

// --------------------------------------------------------------------------
/**
   * Send a chat message to the server.
   * 
   * @param message the text to display.
   */
public static void serverChat(String message) {
    try {
        Minecraft mc = Minecraft.getMinecraft();
        mc.thePlayer.sendChatMessage(message);
    } catch (Exception ex) {
        Log.exception(Level.SEVERE, "Sending chat to the server.", ex);
    }
}
Also used : Minecraft(net.minecraft.client.Minecraft)

Example 72 with Minecraft

use of net.minecraft.client.Minecraft in project watson by totemo.

the class WatsonConfigPanel method mousePressed.

// --------------------------------------------------------------------------
/**
   * @see com.mumfrey.liteloader.modconfig.ConfigPanel#mousePressed(com.mumfrey.liteloader.modconfig.ConfigPanelHost,
   *      int, int, int)
   */
@Override
public void mousePressed(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton) {
    if (_focusedControl != null && _focusedControl instanceof KeyBindingButton) {
        KeyBindingButton button = (KeyBindingButton) _focusedControl;
        // A control is capturing all input. Set a bound key.
        int keyCode = (mouseButton == 0) ? MouseButton.MOUSE_LEFT.getCode() : (mouseButton == 1) ? MouseButton.MOUSE_RIGHT.getCode() : MouseButton.MOUSE_MIDDLE.getCode();
        setModifiedKeyBinding(button.getKeyBinding(), keyCode);
    } else {
        Minecraft mc = Minecraft.getMinecraft();
        // Iterate over all the controls and pass the mouse press to the control
        for (GuiButton control : _keyButtons) {
            // enabled and visible, and the mouse coords are within the control.
            if (control.mousePressed(mc, mouseX, mouseY)) {
                control.playPressSound(mc.getSoundHandler());
                Runnable handler = _handlers.get(control.id);
                if (handler != null) {
                    handler.run();
                }
                break;
            }
        }
    // for
    }
// no control has focus
}
Also used : GuiButton(net.minecraft.client.gui.GuiButton) Minecraft(net.minecraft.client.Minecraft)

Example 73 with Minecraft

use of net.minecraft.client.Minecraft in project watson by totemo.

the class WatsonConfigPanel method getRowHeight.

// setModifiedKeyBinding
// --------------------------------------------------------------------------
/**
   * Return the distance in pixels between the top of one row of controls and
   * the top of the next.
   *
   * @return the distance in pixels between the top of one row of controls and
   *         the top of the next.
   */
protected int getRowHeight() {
    if (_rowHeight == 0) {
        Minecraft mc = Minecraft.getMinecraft();
        FontRenderer fr = mc.fontRendererObj;
        _rowHeight = (int) (fr.FONT_HEIGHT * 2.75);
    }
    return _rowHeight;
}
Also used : FontRenderer(net.minecraft.client.gui.FontRenderer) Minecraft(net.minecraft.client.Minecraft)

Example 74 with Minecraft

use of net.minecraft.client.Minecraft in project watson by totemo.

the class WatsonGuiScreen method initGui.

// --------------------------------------------------------------------------
/**
   * @see GuiScreen#initGui()
   */
@SuppressWarnings("unchecked")
@Override
public void initGui() {
    Minecraft mc = Minecraft.getMinecraft();
    FontRenderer fr = mc.fontRendererObj;
    _rowHeight = (int) (fr.FONT_HEIGHT * 2.75);
    int startY = height / 2 - 4 * _rowHeight;
    int currentRow = 0;
    buttonList.clear();
    buttonList.add(new GuiButton(ID_SHOW_WATSON, width / 2 - 175, startY + currentRow * _rowHeight, 150, 20, getButtonLabel(ID_SHOW_WATSON)));
    buttonList.add(new GuiButton(ID_CLEAR_EDITS, width / 2 + 25, startY + currentRow++ * _rowHeight, 150, 20, getButtonLabel(ID_CLEAR_EDITS)));
    buttonList.add(new GuiButton(ID_SHOW_VECTORS, width / 2 - 175, startY + currentRow * _rowHeight, 150, 20, getButtonLabel(ID_SHOW_VECTORS)));
    GuiResponder sliderResponder = new GuiPageButtonList.GuiResponder() {

        @Override
        public void onTick(int id, float value) {
            // Update the display when the slider slides. Save the new length in
            // the configuration when the GUI closes.
            DisplaySettings ds = Controller.instance.getDisplaySettings();
            ds.setMinVectorLength((int) value, false);
        }

        @Override
        public void func_175321_a(int id, boolean value) {
        }

        @Override
        public void func_175319_a(int id, String value) {
        }
    };
    Configuration config = Configuration.instance;
    GuiSlider slider = new GuiSlider(sliderResponder, ID_MIN_VECTOR_LENGTH, width / 2 + 25, startY + currentRow++ * _rowHeight, "Min Vector Length", 0, 20, config.getVectorLength(), new GuiSlider.FormatHelper() {

        @Override
        public String getText(int id, String name, float value) {
            return "Min Vector Length: " + Integer.toString((int) value);
        }
    });
    buttonList.add(slider);
    buttonList.add(new GuiButton(ID_SHOW_LABELS, width / 2 - 175, startY + currentRow * _rowHeight, 150, 20, getButtonLabel(ID_SHOW_LABELS)));
    buttonList.add(new GuiButton(ID_LABEL_ORDER, width / 2 + 25, startY + currentRow++ * _rowHeight, 150, 20, getButtonLabel(ID_LABEL_ORDER)));
    buttonList.add(new GuiButton(ID_SHOW_ANNOTATIONS, width / 2 - 175, startY + currentRow * _rowHeight, 150, 20, getButtonLabel(ID_SHOW_ANNOTATIONS)));
    buttonList.add(new GuiButton(ID_SHOW_SELECTION, width / 2 + 25, startY + currentRow++ * _rowHeight, 150, 20, getButtonLabel(ID_SHOW_SELECTION)));
    buttonList.add(new GuiOptionButton(ID_DONE, width / 2 - 40, startY + (currentRow + 2) * _rowHeight, 80, 20, I18n.format("gui.done", new Object[0])));
    enableButtons();
}
Also used : GuiResponder(net.minecraft.client.gui.GuiPageButtonList.GuiResponder) Configuration(watson.Configuration) GuiOptionButton(net.minecraft.client.gui.GuiOptionButton) GuiSlider(net.minecraft.client.gui.GuiSlider) Minecraft(net.minecraft.client.Minecraft) GuiButton(net.minecraft.client.gui.GuiButton) FontRenderer(net.minecraft.client.gui.FontRenderer) DisplaySettings(watson.DisplaySettings)

Example 75 with Minecraft

use of net.minecraft.client.Minecraft in project ICBM-Classic by BuiltBrokenModding.

the class TextureTracker method updateAnimation.

@Override
public void updateAnimation() {
    Minecraft minecraft = Minecraft.getMinecraft();
    World world = minecraft.theWorld;
    EntityPlayer player = minecraft.thePlayer;
    double angel = 0;
    if (world != null) {
        double xDifference = 0;
        double zDifference = 0;
        ItemStack itemStack = player.getCurrentEquippedItem();
        if (itemStack != null) {
            if (itemStack.getItem() instanceof ItemTracker) {
                Entity trackingEntity = ((ItemTracker) itemStack.getItem()).getTrackingEntity(FMLClientHandler.instance().getClient().theWorld, itemStack);
                if (trackingEntity != null) {
                    xDifference = trackingEntity.posX - player.posX;
                    zDifference = trackingEntity.posZ - player.posZ;
                }
            }
        }
        player.rotationYaw %= 360.0D;
        angel = -((player.rotationYaw - 90.0D) * Math.PI / 180.0D - Math.atan2(zDifference, xDifference));
    }
    double d6;
    for (d6 = angel - this.currentAngle; d6 < -Math.PI; d6 += (Math.PI * 2D)) {
        ;
    }
    while (d6 >= Math.PI) {
        d6 -= (Math.PI * 2D);
    }
    if (d6 < -1.0D) {
        d6 = -1.0D;
    }
    if (d6 > 1.0D) {
        d6 = 1.0D;
    }
    this.angleDelta += d6 * 0.1D;
    this.angleDelta *= 0.8D;
    this.currentAngle += this.angleDelta;
    int i;
    for (i = (int) ((this.currentAngle / (Math.PI * 2D) + 1.0D) * this.framesTextureData.size()) % this.framesTextureData.size(); i < 0; i = (i + this.framesTextureData.size()) % this.framesTextureData.size()) {
        ;
    }
    if (i != this.frameCounter) {
        this.frameCounter = i;
        TextureUtil.uploadTextureMipmap((int[][]) this.framesTextureData.get(this.frameCounter), this.width, this.height, this.originX, this.originY, false, false);
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft)

Aggregations

Minecraft (net.minecraft.client.Minecraft)84 ScaledResolution (net.minecraft.client.gui.ScaledResolution)15 ItemStack (net.minecraft.item.ItemStack)15 EntityPlayer (net.minecraft.entity.player.EntityPlayer)13 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)10 ResourceLocation (net.minecraft.util.ResourceLocation)7 FontRenderer (net.minecraft.client.gui.FontRenderer)6 Tessellator (net.minecraft.client.renderer.Tessellator)6 ArrayList (java.util.ArrayList)5 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)5 SideOnly (cpw.mods.fml.relauncher.SideOnly)4 WorldClient (net.minecraft.client.multiplayer.WorldClient)4 VertexBuffer (net.minecraft.client.renderer.VertexBuffer)3 World (net.minecraft.world.World)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 GuiAnimatedStat (pneumaticCraft.client.gui.widget.GuiAnimatedStat)3 Rectangle (java.awt.Rectangle)2 File (java.io.File)2 Field (java.lang.reflect.Field)2 Block (net.minecraft.block.Block)2