Java Code Examples for net.minecraft.client.Minecraft.getMinecraft()

The following are Jave code examples for showing how to use getMinecraft() of the net.minecraft.client.Minecraft class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: DecompiledMinecraft   File: RenderGlobal.java   View Source Code Vote up 7 votes
protected Vector3f getViewVector(Entity entityIn, double partialTicks)
{
    float f = (float)((double)entityIn.prevRotationPitch + (double)(entityIn.rotationPitch - entityIn.prevRotationPitch) * partialTicks);
    float f1 = (float)((double)entityIn.prevRotationYaw + (double)(entityIn.rotationYaw - entityIn.prevRotationYaw) * partialTicks);

    if (Minecraft.getMinecraft().gameSettings.thirdPersonView == 2)
    {
        f += 180.0F;
    }

    float f2 = MathHelper.cos(-f1 * 0.017453292F - (float)Math.PI);
    float f3 = MathHelper.sin(-f1 * 0.017453292F - (float)Math.PI);
    float f4 = -MathHelper.cos(-f * 0.017453292F);
    float f5 = MathHelper.sin(-f * 0.017453292F);
    return new Vector3f(f3 * f4, f5, f2 * f4);
}
 
Example 2
Project: Dynamic-GUIs   File: ButtonHandler.java   View Source Code Vote up 6 votes
@Override
		@SideOnly(Side.CLIENT)
		public void manageData(NBTTagCompound tag, MessageContext context) {
			World world = Minecraft.getMinecraft().world;

			if (world != null) {
				EntityPlayer player = (EntityPlayer) world.getEntityByID(tag.getInteger("PlayerID"));
				TileEntity tile = world.getTileEntity(new BlockPos(tag.getInteger("x"), tag.getInteger("y"), tag.getInteger("z")));
				Container container = player.openContainer;

//				if (tile instanceof PagedTileInventory) {
//					((PagedTileInventory) tile).pageChange(tag.getInteger("ButtonID"), player);
//				}
//
//				if (container instanceof PagedContainer) {
//					((PagedContainer) container).pageChange(tag.getInteger("ButtonID"), player);
//				}
			}
		}
 
Example 3
Project: Mods   File: TF2EventsClient.java   View Source Code Vote up 6 votes
@SubscribeEvent
public void renderPlayer(RenderPlayerEvent.Pre event) {
	if (event.getEntityPlayer() != Minecraft.getMinecraft().player) {
		renderBeam(event.getEntityPlayer(), event.getPartialRenderTick());
		/*
		 * InventoryWearables
		 * inventory=event.getEntityPlayer().getCapability(TF2weapons.
		 * INVENTORY_CAP, null); for(int
		 * i=0;i<inventory.getInventoryStackLimit();i++){ ItemStack
		 * stack=inventory.getStackInSlot(i); if(stack!=null){
		 * GlStateManager.pushMatrix();
		 * event.getRenderer().getMainModel().bipedHead.postRender(0.0625f);
		 * GlStateManager.translate(0.0F, -0.25F, 0.0F);
		 * GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
		 * GlStateManager.scale(0.625F, -0.625F, -0.625F);
		 * 
		 * Minecraft.getMinecraft().getItemRenderer().renderItem(event.
		 * getEntityPlayer(), stack,
		 * ItemCameraTransforms.TransformType.HEAD);
		 * GlStateManager.popMatrix(); } }
		 */
	}
}
 
Example 4
Project: pnc-repressurized   File: GuiProgWidgetImportExport.java   View Source Code Vote up 6 votes
@Override
public void initGui() {
    super.initGui();

    if (showSides()) {
        for (int i = 0; i < 6; i++) {
            String sideName = PneumaticCraftUtils.getOrientationName(EnumFacing.getFront(i));
            GuiCheckBox checkBox = new GuiCheckBox(i, guiLeft + 4, guiTop + 30 + i * 12, 0xFF404040, sideName);
            checkBox.checked = ((ProgWidgetInventoryBase) widget).getSides()[i];
            addWidget(checkBox);
        }
    }

    useItemCount = new GuiCheckBox(6, guiLeft + 4, guiTop + (showSides() ? 115 : 30), 0xFF404040, I18n.format("gui.progWidget.itemFilter.useItemCount"));
    useItemCount.setTooltip("gui.progWidget.itemFilter.useItemCount.tooltip");
    useItemCount.checked = ((ICountWidget) widget).useCount();
    addWidget(useItemCount);
    textField = new WidgetTextFieldNumber(Minecraft.getMinecraft().fontRenderer, guiLeft + 7, guiTop + (showSides() ? 128 : 43), 50, 11);
    textField.setValue(((ICountWidget) widget).getCount());
    textField.setEnabled(useItemCount.checked);
    addWidget(textField);
}
 
Example 5
Project: Proyecto-DASI   File: ScreenHelper.java   View Source Code Vote up 6 votes
@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent ev)
{
    purgeExpiredFragments(null);
    if (Minecraft.getMinecraft().currentScreen != null && !(Minecraft.getMinecraft().currentScreen instanceof GuiMainMenu))
        return;

    int displayWidth = Minecraft.getMinecraft().displayWidth;
    int displayHeight = Minecraft.getMinecraft().displayHeight;
    ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft(), displayWidth, displayHeight);
    int width = res.getScaledWidth();
    int height = res.getScaledHeight();
    float rx = (float) width / 1000f;
    float ry = (float) height / 1000f;

    synchronized(this.fragments)
    {
        for (TextCategory cat : TextCategory.values())
        {
            TextCategoryAttributes atts = this.attributes.get(cat);
            if (atts != null && (!atts.flashing || ((System.currentTimeMillis() / 500) % 3 != 0)) && shouldDisplay(atts.displayLevel))
            {
                int x = Math.round(rx * (float) atts.xOrg);
                int y = Math.round(ry * (float) atts.yOrg);
                ArrayList<TextFragment> frags = this.fragments.get(cat);
                if (frags != null && !frags.isEmpty())
                {
                    for (TextFragment frag : frags)
                    {
                        drawText(frag.text, x, y, atts.colour);
                        y += 10;
                    }
                }
            }
        }
    }
}
 
Example 6
Project: Proyecto-DASI   File: FileWorldGeneratorImplementation.java   View Source Code Vote up 6 votes
@Override
public boolean shouldCreateWorld(MissionInit missionInit)
{
    if (this.fwparams != null && this.fwparams.isForceReset())
        return true;

    World world = null;
    MinecraftServer server = MinecraftServer.getServer();
    if (server.worldServers != null && server.worldServers.length != 0)
        world = server.getEntityWorld();

    if (world == null)
        return true;   // There is no world, so we definitely need to create one.

    String name = (world != null) ? world.getWorldInfo().getWorldName() : "";
    // Extract the name from the path (need to cope with backslashes or forward slashes.)
    String mapfile = (this.mapFilename == null) ? "" : this.mapFilename;    // Makes no sense to have an empty filename, but createWorld will deal with it graciously.
    String[] parts = mapfile.split("[\\\\/]");
    if (name.length() > 0 && parts[parts.length - 1].equalsIgnoreCase(name) && Minecraft.getMinecraft().theWorld != null)
        return false;	// We don't check whether the game modes match - it's up to the server state machine to sort that out.

    return true;	// There's no world, or the world is different to the basemap file, so create.
}
 
Example 7
Project: BaseClient   File: Config.java   View Source Code Vote up 5 votes
public static void initGameSettings(GameSettings p_initGameSettings_0_)
{
    if (gameSettings == null)
    {
        gameSettings = p_initGameSettings_0_;
        minecraft = Minecraft.getMinecraft();
        desktopDisplayMode = Display.getDesktopDisplayMode();
        updateAvailableProcessors();
        ReflectorForge.putLaunchBlackboard("optifine.ForgeSplashCompatible", Boolean.TRUE);
    }
}
 
Example 8
Project: TextDisplayer   File: TextEvents.java   View Source Code Vote up 5 votes
private void sendMessage(String message, Object... replacements) {
    if (Minecraft.getMinecraft().thePlayer == null) return; // Safety first! :)

    try {
        message = String.format(message, replacements);
    } catch (Exception ex) { }
    Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText(ChatColor.translateAlternateColorCodes('&', message)));
}
 
Example 9
Project: EMC   File: IMinecraft.java   View Source Code Vote up 5 votes
public static boolean entityHitInstanceOf(EntityType type) {
	if (!isMouseOver()) {
		return false;
	}
	if (type.equals(EntityType.ENTITY_LIVING_BASE)) {
		return Minecraft.getMinecraft().objectMouseOver.entityHit instanceof EntityLivingBase;
	}
	return false;
}
 
Example 10
Project: pnc-repressurized   File: SearchUpgradeHandler.java   View Source Code Vote up 5 votes
@Override
@SideOnly(Side.CLIENT)
public GuiAnimatedStat getAnimatedStat() {
    if (searchInfo == null) {
        Minecraft minecraft = Minecraft.getMinecraft();
        ScaledResolution sr = new ScaledResolution(minecraft);
        searchInfo = new GuiAnimatedStat(null, "Currently searching for:", CraftingRegistrator.getUpgrade(EnumUpgrade.SEARCH), statX != -1 ? statX : sr.getScaledWidth() - 2, statY, 0x3000AA00, null, statLeftSided);
        searchInfo.setMinDimensionsAndReset(0, 0);
    }
    return searchInfo;
}
 
Example 11
Project: DecompiledMinecraft   File: TextureUtil.java   View Source Code Vote up 5 votes
private static void copyToBufferPos(int[] p_110994_0_, int p_110994_1_, int p_110994_2_)
{
    int[] aint = p_110994_0_;

    if (Minecraft.getMinecraft().gameSettings.anaglyph)
    {
        aint = updateAnaglyph(p_110994_0_);
    }

    dataBuffer.clear();
    dataBuffer.put(aint, p_110994_1_, p_110994_2_);
    dataBuffer.position(0).limit(p_110994_2_);
}
 
Example 12
Project: ModularMachinery   File: DynamicMachineRenderContext.java   View Source Code Vote up 5 votes
public Vec2f getCurrentRenderOffset(float x, float z) {
    Minecraft mc = Minecraft.getMinecraft();
    double sc = new ScaledResolution(mc).getScaleFactor();
    double oX = x + 16D / sc;
    double oZ = z + 16D / sc;
    Vec3d tr = getCurrentMachineTranslate();
    return new Vec2f((float) (oX + tr.x), (float) (oZ + tr.z));
}
 
Example 13
Project: Wurst-MC-1.12-OF   File: PasswordField.java   View Source Code Vote up 5 votes
/**
 * Sets focus to this gui element
 */
public void setFocused(boolean isFocusedIn)
{
	if(isFocusedIn && !isFocused)
		cursorCounter = 0;
	
	isFocused = isFocusedIn;
	
	if(Minecraft.getMinecraft().currentScreen != null)
		Minecraft.getMinecraft().currentScreen.func_193975_a(isFocusedIn);
}
 
Example 14
Project: Anima-Mundi   File: GuiShield.java   View Source Code Vote up 5 votes
public void update()
{
	Minecraft mc = Minecraft.getMinecraft();
	ItemStack shieldStack = EntityUtil.getActivePlayerShield(mc.player);
	if(shieldStack.isEmpty())
		return;

	ItemAnimaShield shieldItem = (ItemAnimaShield) shieldStack.getItem();

	float currentCharge = shieldItem.getShieldCharge(shieldStack);
	float maxCharge = shieldItem.getMaxShieldCharge(shieldStack);
	boolean drawFill = currentCharge > 0;

	int asPercent = drawFill ? (int) ((currentCharge * 100)/ maxCharge) : 999;
	float fillWidth = maxBarWidth - (int) (maxBarWidth * ((float)asPercent/100));

	int drawWidth = maxBarWidth - (int)fillWidth;
	if(moveSecondary)
	{
		if(drawWidth < secondaryWidth)
		{
			secondaryWidth--;
		}
		if(drawWidth > secondaryWidth)
		{
			secondaryWidth++;
		}

		if(!drawFill)
		{
			secondaryWidth = 0;
		}
	}
}
 
Example 15
Project: Mods   File: ClientProxy.java   View Source Code Vote up 4 votes
public static EntityPlayer getLocalPlayer() {
	return Minecraft.getMinecraft().player;
}
 
Example 16
Project: VillagerInventory   File: VillagerCareerMessage.java   View Source Code Vote up 4 votes
@Override
public IMessage onMessage(final VillagerCareerMessage message, MessageContext ctx)
{
	Minecraft minecraft = Minecraft.getMinecraft();
	final WorldClient world = minecraft.world;

	minecraft.addScheduledTask(new Runnable()
	{

		@Override
		public void run()
		{
			// get the entity referenced by the specified id
			Entity entity = world.getEntityByID(message.entityId);

			// ensure that the entity is a villager
			if (entity instanceof EntityVillager)
			{
				// cast the entity to type EntityVillager
				EntityVillager villager = (EntityVillager)entity;

				// read the villager's nbt data into a tag compound
				NBTTagCompound compound = new NBTTagCompound();
				villager.writeEntityToNBT(compound);
				// set the career property of the tag compound and write it back to the villager
				compound.setInteger("Career", message.careerId);
				villager.readEntityFromNBT(compound);

				// if there's currently an instance of the villager inventory screen open
				GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
				if (currentScreen != null && currentScreen instanceof GuiVillagerInventory)
				{
					// update the nbt data for the villager attached to the screen from the tag compound
					((GuiVillagerInventory)currentScreen).readVillagerFromNBT(compound);
				}
			}
		}
	});

	return null;
}
 
Example 17
Project: EMC   File: IEntityPlayer.java   View Source Code Vote up 4 votes
public static void setStepHeight(float height) {
	Minecraft.getMinecraft().player.stepHeight = height;
}
 
Example 18
Project: EMC   File: IEntity.java   View Source Code Vote up 4 votes
public boolean isSelf() {
	return entity == Minecraft.getMinecraft().player;
}
 
Example 19
Project: Bewitchment   File: ClientProxy.java   View Source Code Vote up 4 votes
@Override
public boolean isFancyGraphicsEnabled() {
	return Minecraft.getMinecraft().gameSettings.fancyGraphics;
}
 
Example 20
Project: pnc-repressurized   File: IGWSupportNotifier.java   View Source Code Vote up 4 votes
@Override
public void run() {

    try {
        if (Minecraft.getMinecraft().player != null)
            Minecraft.getMinecraft().player.sendStatusMessage(new TextComponentString("Downloading IGW-Mod..."), false);

        URL url = new URL(Loader.MC_VERSION.equals("1.7.10") ? DL_URL_1_7_10 : LATEST_DL_URL);
        URLConnection connection = url.openConnection();
        connection.connect();
        File dir = new File(".", "mods");
        File tempFile = File.createTempFile("IGW-Mod.jar", "");
        FileUtils.copyURLToFile(url, tempFile);

        ZipFile jar = new ZipFile(tempFile.getAbsolutePath());
        Enumeration<? extends ZipEntry> entries = jar.entries();
        InputStream mcmodInfo = null;
        while (entries.hasMoreElements()) {
            ZipEntry entry = entries.nextElement();
            if (entry.getName().equals("mcmod.info")) {
                mcmodInfo = jar.getInputStream(entry);
                break;
            }
        }
        JsonParser parser = new JsonParser();
        JsonObject obj = (JsonObject) ((JsonArray) parser.parse(IOUtils.toString(mcmodInfo))).get(0);
        jar.close();
        String version = obj.get("version").getAsString();
        String mcVersion = obj.get("mcversion").getAsString();
        File renamedFile = new File(String.format("." + File.separator + "mods" + File.separator + "IGW-Mod-%s-%s-universal.jar", mcVersion, version));
        FileUtils.copyFile(tempFile, renamedFile);
        if (Minecraft.getMinecraft().player != null)
            Minecraft.getMinecraft().player.sendStatusMessage(new TextComponentString(TextFormatting.GREEN + "Successfully downloaded. Restart Minecraft to apply."), false);
        Desktop.getDesktop().open(dir);
        if (!Loader.MC_VERSION.equals(mcVersion)) {
            if (Minecraft.getMinecraft().player != null)
                Minecraft.getMinecraft().player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "The version of Minecraft you are running doesn't seem to match the version of IGW-Mod that has been downloaded. The mod may not work."), false);
        }

        finalize();
    } catch (Throwable e) {
        e.printStackTrace();
        if (Minecraft.getMinecraft().player != null)
            Minecraft.getMinecraft().player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "Failed to download"), false);
        try {
            finalize();
        } catch (Throwable e1) {
            e1.printStackTrace();
        }
    }
}