Java Code Examples for net.minecraft.client.MinecraftClient#getInstance()
The following examples show how to use
net.minecraft.client.MinecraftClient#getInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MixinPlayerEntity.java From bleachhack-1.14 with GNU General Public License v3.0 | 6 votes |
@Inject(at = @At("RETURN"), method = "tick()V", cancellable = true) public void tick(CallbackInfo info) { try { if (MinecraftClient.getInstance().player.age % 100 == 0) { BleachFileHelper.saveModules(); BleachFileHelper.saveSettings(); BleachFileHelper.saveBinds(); BleachFileHelper.saveClickGui(); } BleachQueue.nextQueue(); } catch (Exception e) {} EventTick event = new EventTick(); BleachHack.eventBus.post(event); if (event.isCancelled()) info.cancel(); }
Example 2
Source File: MixinMinecraftClient.java From Sandbox with GNU Lesser General Public License v3.0 | 6 votes |
@ModifyVariable(method = "openScreen", at = @At("HEAD"), ordinal = 0) public Screen openScreen(Screen screen) { if (screen instanceof TitleScreen || (screen == null && MinecraftClient.getInstance().world == null)) { screen = new SandboxTitleScreen(); } return screen; }
Example 3
Source File: MixinPlayerEntity.java From bleachhack-1.14 with GNU General Public License v3.0 | 6 votes |
@Inject(at = @At("RETURN"), method = "tick()V", cancellable = true) public void tick(CallbackInfo info) { try { if (MinecraftClient.getInstance().player.age % 100 == 0) { BleachFileHelper.saveModules(); BleachFileHelper.saveSettings(); BleachFileHelper.saveBinds(); BleachFileHelper.saveClickGui(); } BleachQueue.nextQueue(); } catch (Exception e) {} EventTick event = new EventTick(); BleachHack.eventBus.post(event); if (event.isCancelled()) info.cancel(); }
Example 4
Source File: MixinBootstrapClient.java From Sandbox with GNU Lesser General Public License v3.0 | 5 votes |
@Inject(method = "initialize", at = @At("HEAD")) private static void init(CallbackInfo info) { if (!initialized) { SandboxCommon.client = (Client) MinecraftClient.getInstance(); SandboxHooks.setupGlobal(); } }
Example 5
Source File: NotebotUtils.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
private static void play(SoundEvent sound, float pitch) { if (MinecraftClient.getInstance().world != null && MinecraftClient.getInstance().player != null) { MinecraftClient.getInstance().world.playSound(MinecraftClient.getInstance().player, MinecraftClient.getInstance().player.getBlockPos(), sound, SoundCategory.RECORDS, 3.0F, pitch); } else { MinecraftClient.getInstance().getSoundManager().play( new PositionedSoundInstance(sound, SoundCategory.RECORDS, 3.0F, pitch, 0F, 0F, 0F)); } }
Example 6
Source File: WLabel.java From LibGui with MIT License | 5 votes |
@Environment(EnvType.CLIENT) @Override public void onClick(int x, int y, int button) { Style hoveredTextStyle = getTextStyleAt(x, y); if (hoveredTextStyle != null) { Screen screen = MinecraftClient.getInstance().currentScreen; if (screen != null) { screen.handleTextClick(hoveredTextStyle); } } }
Example 7
Source File: Window.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
public void render(int mX, int mY) { TextRenderer textRend = MinecraftClient.getInstance().textRenderer; if (dragging) { x2 = (x2 - x1) + mX - dragOffX; y2 = (y2 - y1) + mY - dragOffY; x1 = mX - dragOffX; y1 = mY - dragOffY; } drawBar(mX, mY, textRend); for (WindowButton w: buttons) { int bx1 = x1 + w.x1; int by1 = y1 + w.y1; int bx2 = x1 + w.x2; int by2 = y1 + w.y2; Screen.fill(bx1, by1, bx2 - 1, by2 - 1, 0xffb0b0b0); Screen.fill(bx1 + 1, by1 + 1, bx2, by2, 0xff000000); Screen.fill(bx1 + 1, by1 + 1, bx2 - 1, by2 - 1, selected && mX >= bx1 && mX <= bx2 && mY >= by1 && mY <= by2 ? 0xff959595 : 0xff858585); textRend.drawWithShadow(w.text, bx1 + (bx2 - bx1) / 2 - textRend.getStringWidth(w.text) / 2, by1 + (by2 - by1) / 2 - 4, -1); } /* window icon */ if (icon != null && selected) { GL11.glPushMatrix(); GL11.glScaled(0.55, 0.55, 1); DiffuseLighting.enableGuiDepthLighting(); MinecraftClient.getInstance().getItemRenderer().renderGuiItem(icon, (int)((x1 + 3) * 1/0.55), (int)((y1 + 3) * 1/0.55)); GL11.glPopMatrix(); } /* window title */ textRend.drawWithShadow(title, x1 + (icon == null || !selected || icon.getItem() == Items.AIR ? 4 : 15), y1 + 3, -1); }
Example 8
Source File: WText.java From LibGui with MIT License | 5 votes |
/** * Gets the text style at the specific widget-space coordinates. * * @param x the X coordinate in widget space * @param y the Y coordinate in widget space * @return the text style at the position, or null if not found */ @Environment(EnvType.CLIENT) @Nullable public Style getTextStyleAt(int x, int y) { TextRenderer font = MinecraftClient.getInstance().textRenderer; int lineIndex = y / font.fontHeight; if (lineIndex >= 0 && lineIndex < wrappedLines.size()) { StringRenderable line = wrappedLines.get(lineIndex); return font.getTextHandler().trimToWidth(line, x); } return null; }
Example 9
Source File: NotebotUtils.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
private static void play(SoundEvent sound, float pitch) { if (MinecraftClient.getInstance().world != null && MinecraftClient.getInstance().player != null) { MinecraftClient.getInstance().world.playSound(MinecraftClient.getInstance().player, MinecraftClient.getInstance().player.getBlockPos(), sound, SoundCategory.RECORDS, 3.0F, pitch); } else { MinecraftClient.getInstance().getSoundManager().play( new PositionedSoundInstance(sound, SoundCategory.RECORDS, 3.0F, pitch, 0F, 0F, 0F)); } }
Example 10
Source File: WItem.java From LibGui with MIT License | 5 votes |
@Environment(EnvType.CLIENT) @Override public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) { RenderSystem.enableDepthTest(); MinecraftClient mc = MinecraftClient.getInstance(); ItemRenderer renderer = mc.getItemRenderer(); renderer.zOffset = 100f; renderer.renderInGui(items.get(current), x + getWidth() / 2 - 9, y + getHeight() / 2 - 9); renderer.zOffset = 0f; }
Example 11
Source File: WWidget.java From LibGui with MIT License | 5 votes |
/** * Internal method to render tooltip data. This requires an overriden {@link #addTooltip(List) * addTooltip} method to insert data into the tooltip - without this, the method returns early, because no work */ @Environment(EnvType.CLIENT) public void renderTooltip(MatrixStack matrices, int x, int y, int tX, int tY) { List<StringRenderable> info = new ArrayList<>(); addTooltip(info); if (info.size() == 0) return; Screen screen = MinecraftClient.getInstance().currentScreen; screen.renderTooltip(matrices, info, tX+x, tY+y); }
Example 12
Source File: WItemSlot.java From LibGui with MIT License | 5 votes |
@Environment(EnvType.CLIENT) @Override public void onKeyPressed(int ch, int key, int modifiers) { if (isActivationKey(ch) && host instanceof ScreenHandler && focusedSlot >= 0) { ScreenHandler handler = (ScreenHandler) host; MinecraftClient client = MinecraftClient.getInstance(); ValidatedSlot peer = peers.get(focusedSlot); client.interactionManager.clickSlot(handler.syncId, peer.id, 0, SlotActionType.PICKUP, client.player); } }
Example 13
Source File: NotebotUtils.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
private static void play(SoundEvent sound, float pitch) { if (MinecraftClient.getInstance().world != null && MinecraftClient.getInstance().player != null) { MinecraftClient.getInstance().world.playSound(MinecraftClient.getInstance().player, MinecraftClient.getInstance().player.getBlockPos(), sound, SoundCategory.RECORDS, 3.0F, pitch); } else { MinecraftClient.getInstance().getSoundManager().play( new PositionedSoundInstance(sound, SoundCategory.RECORDS, 3.0F, pitch, 0F, 0F, 0F)); } }
Example 14
Source File: Window.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
public void render(int mX, int mY) { TextRenderer textRend = MinecraftClient.getInstance().textRenderer; if (dragging) { x2 = (x2 - x1) + mX - dragOffX; y2 = (y2 - y1) + mY - dragOffY; x1 = mX - dragOffX; y1 = mY - dragOffY; } drawBar(mX, mY, textRend); for (WindowButton w: buttons) { int bx1 = x1 + w.x1; int by1 = y1 + w.y1; int bx2 = x1 + w.x2; int by2 = y1 + w.y2; Screen.fill(bx1, by1, bx2 - 1, by2 - 1, 0xffb0b0b0); Screen.fill(bx1 + 1, by1 + 1, bx2, by2, 0xff000000); Screen.fill(bx1 + 1, by1 + 1, bx2 - 1, by2 - 1, selected && mX >= bx1 && mX <= bx2 && mY >= by1 && mY <= by2 ? 0xff959595 : 0xff858585); textRend.drawWithShadow(w.text, bx1 + (bx2 - bx1) / 2 - textRend.getStringWidth(w.text) / 2, by1 + (by2 - by1) / 2 - 4, -1); } /* window icon */ if (icon != null && selected) { GL11.glPushMatrix(); GL11.glScaled(0.55, 0.55, 1); GuiLighting.enable(); MinecraftClient.getInstance().getItemRenderer().renderGuiItem(icon, (int)((x1 + 3) * 1/0.55), (int)((y1 + 3) * 1/0.55)); GL11.glPopMatrix(); } /* window title */ textRend.drawWithShadow(title, x1 + (icon == null || !selected ? 4 : 15), y1 + 3, -1); }
Example 15
Source File: BleachCheckbox.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
public void renderButton(MatrixStack matrix, int mouseX, int mouseY, float delta) { MinecraftClient minecraftClient_1 = MinecraftClient.getInstance(); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_DEPTH_TEST); TextRenderer textRenderer = minecraftClient_1.textRenderer; int color = mouseX > x && mouseX < x + 10 && mouseY > y && mouseY < y + 10 ? 0xffc0c0c0 : 0xffe0e0e0; fill(matrix, x, y, x + 11, y + 11, color); fill(matrix, x, y, x + 1, y + 11, 0xff303030); fill(matrix, x, y + 10, x + 11, y + 11, 0xffb0b0b0); fill(matrix, x, y, x + 10, y + 1, 0xff303030); fill(matrix, x + 10, y, x + 11, y + 11, 0xffb0b0b0); if (checked) textRenderer.draw(matrix, "\u2714", x + 2, y + 2, 0x000000); //fill(x + 3, y + 5, x + 8, y + 6, 0xff000000); drawStringWithShadow(matrix, textRenderer, getMessage().getString(), x + 15, y + 2, 0xC0C0C0); }
Example 16
Source File: PlayerCopyEntity.java From bleachhack-1.14 with GNU General Public License v3.0 | 4 votes |
public PlayerCopyEntity(GameProfile profile) { this(profile, MinecraftClient.getInstance().player.x, MinecraftClient.getInstance().player.y, MinecraftClient.getInstance().player.z); }
Example 17
Source File: WText.java From LibGui with MIT License | 4 votes |
@Environment(EnvType.CLIENT) private void wrapLines() { TextRenderer font = MinecraftClient.getInstance().textRenderer; wrappedLines = font.wrapLines(text, width); }
Example 18
Source File: PlayerCopyEntity.java From bleachhack-1.14 with GNU General Public License v3.0 | 4 votes |
public PlayerCopyEntity(GameProfile profile, double x, double y, double z) { super(MinecraftClient.getInstance().world, profile); setPos(x, y, z); }
Example 19
Source File: ModuleWindowDark.java From bleachhack-1.14 with GNU General Public License v3.0 | 4 votes |
public void draw(int mX, int mY, int leng) { mouseX = mX; mouseY = mY; len = leng; font = MinecraftClient.getInstance().textRenderer; Screen.fill(posX, posY-10, posX+len, posY, mouseOver(posX, posY-10, posX+len, posY) ? 0x90101010 : 0x90303030); font.drawWithShadow(name, posX+(len/2)-(font.getStringWidth(name)/2), posY-9, 0x70afa0); /* window dragging */ if (mouseOver(posX, posY-10, posX+len, posY)) { if (rmDown) hiding = !hiding; if (lmDown) dragging = true; } if (!lmHeld) dragging = false; if (dragging) { posX = mouseX-(prevmX - posX); posY = mouseY-(prevmY - posY); } prevmX = mouseX; prevmY = mouseY; /* Draw Modules */ if (hiding) { font.drawWithShadow("-", posX+len-8, posY-9, 0x70afa0); return; } else font.drawWithShadow("+", posX+len-8, posY-9, 0x70afa0); int count = 0; for (Entry<Module, Boolean> m: new LinkedHashMap<>(mods).entrySet()) { Screen.fill(posX, posY+(count*12), posX+len, posY+12+(count*12), mouseOver(posX, posY+(count*12), posX+len, posY+12+(count*12)) ? 0x70303070 : 0x70000000); font.drawWithShadow(cutText(m.getKey().getName(), len), posX+2, posY+2+(count*12), m.getKey().isToggled() ? 0x70efe0 : 0xc0c0c0); Screen.fill(m.getValue() ? posX+len-2 : posX+len-1, posY+(count*12), posX+len, posY+12+(count*12), m.getValue() ? 0x9f70fff0 : 0x5f70fff0); /* Set which module settings show on */ if (mouseOver(posX, posY+(count*12), posX+len, posY+12+(count*12))) { GL11.glTranslated(0, 0, 300); /* Match lines to end of words */ Matcher mat = Pattern.compile("\\b.{1,22}\\b\\W?").matcher(m.getKey().getDesc()); int c2 = 0; int c3 = 0; while(mat.find()) { c2++; } mat.reset(); while(mat.find()) { Screen.fill(posX+len+3, posY-1+(count*12)-(c2 * 10)+(c3 * 10), posX+len+6+font.getStringWidth(mat.group().trim()), posY+(count*12)-(c2 * 10)+(c3 * 10)+9, 0x90000000); font.drawWithShadow(mat.group(), posX+len+5, posY+(count*12)-(c2 * 10)+(c3 * 10), -1); c3++; } if (lmDown) m.getKey().toggle(); if (rmDown) mods.replace(m.getKey(), !m.getValue()); if (lmDown || rmDown) MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F)); GL11.glTranslated(0, 0, -300); } /* draw settings */ if (m.getValue()) { for (SettingBase s: m.getKey().getSettings()) { count++; if (s instanceof SettingMode) drawModeSetting(s.toMode(), posX, posY+(count*12)); if (s instanceof SettingToggle) drawToggleSetting(s.toToggle(), posX, posY+(count*12)); if (s instanceof SettingSlider) drawSliderSetting(s.toSlider(), posX, posY+(count*12)); Screen.fill(posX+len-1, posY+(count*12), posX+len, posY+12+(count*12), 0x9f70fff0); } count++; drawBindSetting(m.getKey(), keyDown, posX, posY+(count*12)); Screen.fill(posX+len-1, posY+(count*12), posX+len, posY+12+(count*12), 0x9f70fff0); } count++; } lmDown = false; rmDown = false; keyDown = -1; }
Example 20
Source File: BackgroundPonyList.java From MineLittlePony with MIT License | 4 votes |
private boolean isUser(UUID uuid) { return MinecraftClient.getInstance().player != null && MinecraftClient.getInstance().player.getUuid().equals(uuid); }