Search in sources :

Example 31 with Minecraft

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

the class WatsonConfigPanel method drawPanel.

// onTick
// --------------------------------------------------------------------------
/**
   * Draw the title and all the controls.
   *
   * @see com.mumfrey.liteloader.modconfig.ConfigPanel#drawPanel(com.mumfrey.liteloader.modconfig.ConfigPanelHost,
   *      int, int, float)
   */
@Override
public void drawPanel(ConfigPanelHost host, int mouseX, int mouseY, float partialTicks) {
    Minecraft mc = Minecraft.getMinecraft();
    FontRenderer fr = mc.fontRendererObj;
    int labelHeight = (int) (0.75 * fr.FONT_HEIGHT);
    drawCenteredString(fr, "Key Bindings", host.getWidth() / 2, labelHeight, 0xFFFFFF55);
    for (KeyBindingButton control : _keyButtons) {
        control.drawString(fr, control.getKeyBinding().getDescription(), 0, labelHeight + (control.id + 1) * _rowHeight, 0xFFFFFFFF);
        control.drawButton(mc, mouseX, mouseY);
    }
}
Also used : FontRenderer(net.minecraft.client.gui.FontRenderer) Minecraft(net.minecraft.client.Minecraft)

Example 32 with Minecraft

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

the class Controller method getServerIP.

// --------------------------------------------------------------------------
/**
   * Return the IP address or DNS name of the currently connected server, or
   * null if not connected.
   *
   * @return the IP address or DNS name of the currently connected server, or
   *         null if not connected.
   */
public String getServerIP() {
    Minecraft mc = Minecraft.getMinecraft();
    ServerData serverData = mc.getCurrentServerData();
    if (!mc.isSingleplayer() && serverData != null) {
        return serverData.serverIP;
    } else {
        return null;
    }
}
Also used : ServerData(net.minecraft.client.multiplayer.ServerData) Minecraft(net.minecraft.client.Minecraft)

Example 33 with Minecraft

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

the class Controller method initialise.

// --------------------------------------------------------------------------
/**
   * Mod-wide initialisation tasks, including loading configuration files and
   * setting up commands.
   */
public void initialise() {
    createBlockEditDirectory();
    BlockTypeRegistry.instance.loadBlockTypes();
    Chat.getChatHighlighter().loadHighlights();
    // Initialise the commands.
    ClientCommandManager.instance.registerCommand(new WatsonCommand());
    ClientCommandManager.instance.registerCommand(new AnnoCommand());
    ClientCommandManager.instance.registerCommand(new HighlightCommand());
    ClientCommandManager.instance.registerCommand(new CalcCommand());
    // Set up event handlers for key bindings.
    final Configuration config = Configuration.instance;
    config.KEYBIND_INGAME.setDisplayDependent(false);
    config.KEYBIND_INGAME.setHandler(new Runnable() {

        @Override
        public void run() {
            Minecraft.getMinecraft().displayGuiScreen(new WatsonGuiScreen());
        }
    });
    config.KEYBIND_SCREENSHOT.setDisplayDependent(false);
    config.KEYBIND_SCREENSHOT.setHandler(new Runnable() {

        @Override
        public void run() {
            Date now = new Date();
            Configuration config = Configuration.instance;
            String player = (String) Controller.instance.getVariables().get("player");
            String subdirectoryName = (player != null && config.isSsPlayerDirectory()) ? player : config.getSsDateDirectory().format(now).toString();
            Minecraft mc = Minecraft.getMinecraft();
            File screenshotsDir = new File(mc.mcDataDir, "screenshots");
            File subdirectory = new File(screenshotsDir, subdirectoryName);
            File file = Screenshot.getUniqueFilename(subdirectory, player, now);
            Chat.localChat(Screenshot.save(file, mc.displayWidth, mc.displayHeight));
        }
    });
    config.KEYBIND_TP_NEXT.setHandler(new Runnable() {

        @Override
        public void run() {
            getBlockEditSet().getOreDB().tpNext();
        }
    });
    config.KEYBIND_TP_PREV.setHandler(new Runnable() {

        @Override
        public void run() {
            getBlockEditSet().getOreDB().tpPrev();
        }
    });
    Controller.instance.queryPreEdits(config.getPreCount());
    config.KEYBIND_QUERY_BEFORE.setHandler(new Runnable() {

        @Override
        public void run() {
            queryPreEdits(config.getPreCount());
        }
    });
    config.KEYBIND_QUERY_AFTER.setHandler(new Runnable() {

        @Override
        public void run() {
            queryPostEdits(config.getPostCount());
        }
    });
    config.KEYBIND_CURSOR_NEXT.setHandler(new Runnable() {

        @Override
        public void run() {
            // in which case it does not belong to a set of player edits.
            if (_selection != null && _selection.playerEditSet != null) {
                BlockEdit edit = _selection.playerEditSet.getEditAfter(_selection);
                if (edit != null) {
                    selectBlockEdit(edit);
                }
            }
        }
    });
    config.KEYBIND_CURSOR_PREV.setHandler(new Runnable() {

        @Override
        public void run() {
            // in which case it does not belong to a set of player edits.
            if (_selection != null && _selection.playerEditSet != null) {
                BlockEdit edit = _selection.playerEditSet.getEditBefore(_selection);
                if (edit != null) {
                    selectBlockEdit(edit);
                }
            }
        }
    });
    config.KEYBIND_TP_CURSOR.setHandler(new Runnable() {

        @Override
        public void run() {
            if (_selection != null) {
                teleport(_selection.x, _selection.y, _selection.z);
            }
        }
    });
}
Also used : WatsonCommand(watson.cli.WatsonCommand) WatsonGuiScreen(watson.gui.WatsonGuiScreen) HighlightCommand(watson.cli.HighlightCommand) Minecraft(net.minecraft.client.Minecraft) Date(java.util.Date) AnnoCommand(watson.cli.AnnoCommand) CalcCommand(watson.cli.CalcCommand) BlockEdit(watson.db.BlockEdit) File(java.io.File)

Example 34 with Minecraft

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

the class Controller method getBlockEditSet.

// --------------------------------------------------------------------------
/**
   * Return the current {@link BlockEditSet} under examination.
   *
   * A separate {@link BlockEditSet} is maintained for each dimension
   * (overworld, nether, end).
   *
   * @return the current {@link BlockEditSet} under examination.
   */
public BlockEditSet getBlockEditSet() {
    // Compute id of the form: address/dimension
    // Note: Minecraft.theWorld.getWorldInfo().getDimension() doesn't update.
    Minecraft mc = Minecraft.getMinecraft();
    StringBuilder idBuilder = new StringBuilder();
    // This code might get referenced at startup when changing display settings
    // if the mod happens to be disabled in the config file. At that time,
    // getServerIP() will be null. Let's avoid that crash.
    String serverIP = getServerIP();
    if (serverIP != null) {
        idBuilder.append(serverIP);
    }
    idBuilder.append('/');
    idBuilder.append(mc.thePlayer.dimension);
    String id = idBuilder.toString();
    // Lookup BlockEditSet or create new mapping if not found.
    BlockEditSet edits = _edits.get(id);
    if (edits == null) {
        edits = new BlockEditSet();
        _edits.put(id, edits);
    }
    return edits;
}
Also used : Minecraft(net.minecraft.client.Minecraft) BlockEditSet(watson.db.BlockEditSet)

Example 35 with Minecraft

use of net.minecraft.client.Minecraft in project RFToolsDimensions by McJty.

the class SkyRenderer method renderClouds.

@SideOnly(Side.CLIENT)
public static void renderClouds(GenericWorldProvider provider, DimensionInformation information, float partialTicks) {
    GlStateManager.disableCull();
    Minecraft mc = Minecraft.getMinecraft();
    TextureManager renderEngine = mc.getTextureManager();
    float f1 = (float) (mc.getRenderViewEntity().lastTickPosY + (mc.getRenderViewEntity().posY - mc.getRenderViewEntity().lastTickPosY) * partialTicks);
    Tessellator tessellator = Tessellator.getInstance();
    float f2 = 12.0F;
    float f3 = 4.0F;
    RenderGlobal renderGlobal = mc.renderGlobal;
    double d0 = (CloudRenderAccessHelper.getCloudTickCounter(renderGlobal) + partialTicks);
    double entityX = mc.getRenderViewEntity().prevPosX + (mc.getRenderViewEntity().posX - mc.getRenderViewEntity().prevPosX) * partialTicks;
    double entityZ = mc.getRenderViewEntity().prevPosZ + (mc.getRenderViewEntity().posZ - mc.getRenderViewEntity().prevPosZ) * partialTicks;
    double d1 = (entityX + d0 * 0.029999999329447746D) / f2;
    double d2 = entityZ / f2 + 0.33000001311302185D;
    float y = provider.getCloudHeight() - f1 + 0.33F;
    int i = MathTools.floor(d1 / 2048.0D);
    int j = MathTools.floor(d2 / 2048.0D);
    d1 -= (i * 2048);
    d2 -= (j * 2048);
    renderEngine.bindTexture(locationCloudsPng);
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    Vec3d vec3 = provider.getWorld().getCloudColour(partialTicks);
    float red = (float) vec3.xCoord;
    float green = (float) vec3.yCoord;
    float blue = (float) vec3.zCoord;
    float f8;
    float f9;
    float f10;
    if (mc.gameSettings.anaglyph) {
        f8 = (red * 30.0F + green * 59.0F + blue * 11.0F) / 100.0F;
        f9 = (red * 30.0F + green * 70.0F) / 100.0F;
        f10 = (red * 30.0F + blue * 70.0F) / 100.0F;
        red = f8;
        green = f9;
        blue = f10;
    }
    f10 = 0.00390625F;
    f8 = MathTools.floor(d1) * f10;
    f9 = MathTools.floor(d2) * f10;
    float f11 = (float) (d1 - MathTools.floor(d1));
    float f12 = (float) (d2 - MathTools.floor(d2));
    byte b0 = 8;
    byte b1 = 4;
    float f13 = 9.765625E-4F;
    GlStateManager.scale(f2, 1.0F, f2);
    float cr = information.getSkyDescriptor().getCloudColorFactorR();
    float cg = information.getSkyDescriptor().getCloudColorFactorG();
    float cb = information.getSkyDescriptor().getCloudColorFactorB();
    boolean randomColors = information.isPatreonBitSet(Patreons.PATREON_KENNEY);
    VertexBuffer renderer = tessellator.getBuffer();
    for (int k = 0; k < 2; ++k) {
        if (k == 0) {
            GlStateManager.colorMask(false, false, false, false);
        } else if (mc.gameSettings.anaglyph) {
            if (EntityRenderer.anaglyphField == 0) {
                GlStateManager.colorMask(false, true, true, true);
            } else {
                GlStateManager.colorMask(true, false, false, true);
            }
        } else {
            GlStateManager.colorMask(true, true, true, true);
        }
        for (int l = -b1 + 1; l <= b1; ++l) {
            for (int i1 = -b1 + 1; i1 <= b1; ++i1) {
                renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL);
                float u = (l * b0);
                float v = (i1 * b0);
                float x = u - f11;
                float z = v - f12;
                if (randomColors) {
                    //                        cr = (float) ((u % 10.0f) / 10.0f);
                    //                        cg = (float) (((u + v) % 10.0f) / 10.0f);
                    //                        cb = (float) ((v % 10.0f) / 10.0f);
                    cr = x % 1.0f;
                    cg = (x + z) % 1.0f;
                    cb = z % 1.0f;
                }
                if (y > -f3 - 1.0F) {
                    renderer.pos((x + 0.0F), (y + 0.0F), (z + b0)).tex(((u + 0.0F) * f10 + f8), ((v + b0) * f10 + f9)).color(red * 0.7F * cr, green * 0.7F * cg, blue * 0.7F * cb, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
                    renderer.pos((x + b0), (y + 0.0F), (z + b0)).tex(((u + b0) * f10 + f8), ((v + b0) * f10 + f9)).color(red * 0.7F * cr, green * 0.7F * cg, blue * 0.7F * cb, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
                    renderer.pos((x + b0), (y + 0.0F), (z + 0.0F)).tex(((u + b0) * f10 + f8), ((v + 0.0F) * f10 + f9)).color(red * 0.7F * cr, green * 0.7F * cg, blue * 0.7F * cb, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
                    renderer.pos((x + 0.0F), (y + 0.0F), (z + 0.0F)).tex(((u + 0.0F) * f10 + f8), ((v + 0.0F) * f10 + f9)).color(red * 0.7F * cr, green * 0.7F * cg, blue * 0.7F * cb, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
                }
                if (y <= f3 + 1.0F) {
                    renderer.pos((x + 0.0F), (y + f3 - f13), (z + b0)).tex(((u + 0.0F) * f10 + f8), ((v + b0) * f10 + f9)).color(red * cr, green * cg, blue * cb, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
                    renderer.pos((x + b0), (y + f3 - f13), (z + b0)).tex(((u + b0) * f10 + f8), ((v + b0) * f10 + f9)).color(red * cr, green * cg, blue * cb, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
                    renderer.pos((x + b0), (y + f3 - f13), (z + 0.0F)).tex(((u + b0) * f10 + f8), ((v + 0.0F) * f10 + f9)).color(red * cr, green * cg, blue * cb, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
                    renderer.pos((x + 0.0F), (y + f3 - f13), (z + 0.0F)).tex(((u + 0.0F) * f10 + f8), ((v + 0.0F) * f10 + f9)).color(red * cr, green * cg, blue * cb, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
                }
                int j1;
                if (l > -1) {
                    for (j1 = 0; j1 < b0; ++j1) {
                        renderer.pos((x + j1 + 0.0F), (y + 0.0F), (z + b0)).tex(((u + j1 + 0.5F) * f10 + f8), ((v + b0) * f10 + f9)).color(red * 0.9F * cr, green * 0.9F * cg, blue * 0.9F * cb, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
                        renderer.pos((x + j1 + 0.0F), (y + f3), (z + b0)).tex(((u + j1 + 0.5F) * f10 + f8), ((v + b0) * f10 + f9)).color(red * 0.9F * cr, green * 0.9F * cg, blue * 0.9F * cb, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
                        renderer.pos((x + j1 + 0.0F), (y + f3), (z + 0.0F)).tex(((u + j1 + 0.5F) * f10 + f8), ((v + 0.0F) * f10 + f9)).color(red * 0.9F * cr, green * 0.9F * cg, blue * 0.9F * cb, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
                        renderer.pos((x + j1 + 0.0F), (y + 0.0F), (z + 0.0F)).tex(((u + j1 + 0.5F) * f10 + f8), ((v + 0.0F) * f10 + f9)).color(red * 0.9F * cr, green * 0.9F * cg, blue * 0.9F * cb, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
                    }
                }
                if (l <= 1) {
                    for (j1 = 0; j1 < b0; ++j1) {
                        renderer.pos((x + j1 + 1.0F - f13), (y + 0.0F), (z + b0)).tex(((u + j1 + 0.5F) * f10 + f8), ((v + b0) * f10 + f9)).color(red * 0.9F * cr, green * 0.9F * cg, blue * 0.9F * cb, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
                        renderer.pos((x + j1 + 1.0F - f13), (y + f3), (z + b0)).tex(((u + j1 + 0.5F) * f10 + f8), ((v + b0) * f10 + f9)).color(red * 0.9F * cr, green * 0.9F * cg, blue * 0.9F * cb, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
                        renderer.pos((x + j1 + 1.0F - f13), (y + f3), (z + 0.0F)).tex(((u + j1 + 0.5F) * f10 + f8), ((v + 0.0F) * f10 + f9)).color(red * 0.9F * cr, green * 0.9F * cg, blue * 0.9F * cb, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
                        renderer.pos((x + j1 + 1.0F - f13), (y + 0.0F), (z + 0.0F)).tex(((u + j1 + 0.5F) * f10 + f8), ((v + 0.0F) * f10 + f9)).color(red * 0.9F * cr, green * 0.9F * cg, blue * 0.9F * cb, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
                    }
                }
                if (i1 > -1) {
                    for (j1 = 0; j1 < b0; ++j1) {
                        renderer.pos((x + 0.0F), (y + f3), (z + j1 + 0.0F)).tex(((u + 0.0F) * f10 + f8), ((v + j1 + 0.5F) * f10 + f9)).color(red * 0.8F * cr, green * 0.8F * cg, blue * 0.8F * cb, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
                        renderer.pos((x + b0), (y + f3), (z + j1 + 0.0F)).tex(((u + b0) * f10 + f8), ((v + j1 + 0.5F) * f10 + f9)).color(red * 0.8F * cr, green * 0.8F * cg, blue * 0.8F * cb, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
                        renderer.pos((x + b0), (y + 0.0F), (z + j1 + 0.0F)).tex(((u + b0) * f10 + f8), ((v + j1 + 0.5F) * f10 + f9)).color(red * 0.8F * cr, green * 0.8F * cg, blue * 0.8F * cb, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
                        renderer.pos((x + 0.0F), (y + 0.0F), (z + j1 + 0.0F)).tex(((u + 0.0F) * f10 + f8), ((v + j1 + 0.5F) * f10 + f9)).color(red * 0.8F * cr, green * 0.8F * cg, blue * 0.8F * cb, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
                    }
                }
                if (i1 <= 1) {
                    for (j1 = 0; j1 < b0; ++j1) {
                        renderer.pos((x + 0.0F), (y + f3), (z + j1 + 1.0F - f13)).tex(((u + 0.0F) * f10 + f8), ((v + j1 + 0.5F) * f10 + f9)).color(red * 0.8F * cr, green * 0.8F * cg, blue * 0.8F * cb, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
                        renderer.pos((x + b0), (y + f3), (z + j1 + 1.0F - f13)).tex(((u + b0) * f10 + f8), ((v + j1 + 0.5F) * f10 + f9)).color(red * 0.8F * cr, green * 0.8F * cg, blue * 0.8F * cb, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
                        renderer.pos((x + b0), (y + 0.0F), (z + j1 + 1.0F - f13)).tex(((u + b0) * f10 + f8), ((v + j1 + 0.5F) * f10 + f9)).color(red * 0.8F * cr, green * 0.8F * cg, blue * 0.8F * cb, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
                        renderer.pos((x + 0.0F), (y + 0.0F), (z + j1 + 1.0F - f13)).tex(((u + 0.0F) * f10 + f8), ((v + j1 + 0.5F) * f10 + f9)).color(red * 0.8F * cr, green * 0.8F * cg, blue * 0.8F * cb, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
                    }
                }
                tessellator.draw();
            }
        }
    }
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.disableBlend();
    GlStateManager.enableCull();
}
Also used : TextureManager(net.minecraft.client.renderer.texture.TextureManager) Minecraft(net.minecraft.client.Minecraft) Vec3d(net.minecraft.util.math.Vec3d) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

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