Search in sources :

Example 31 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project FZMM-Mod by Zailer43.

the class EncodebookLogic method showDecoderInChat.

public static void showDecoderInChat(final int SEED, final int MAX_MESSAGE_LENGTH) {
    MinecraftClient mc = MinecraftClient.getInstance();
    String translationKeyPrefix = Configs.Encodebook.TRANSLATION_KEY_PREFIX.getStringValue();
    StringBuilder decoderString = new StringBuilder();
    short[] encodeKey = encodeKey(getKey(SEED), MAX_MESSAGE_LENGTH);
    assert mc.player != null;
    for (int i = 0; i < MAX_MESSAGE_LENGTH; i++) {
        decoderString.append("%").append(encodeKey[i] + 1).append("$s");
    }
    MutableText decoderMessage = new LiteralText(Formatting.GREEN + translationKeyPrefix + SEED).setStyle(Style.EMPTY.withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, "\"" + translationKeyPrefix + SEED + "\": \"" + decoderString + "\"")).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(decoderString.toString()))));
    mc.inGameHud.addChatMessage(MessageType.SYSTEM, decoderMessage, mc.player.getUuid());
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient)

Example 32 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project tweakermore by Fallen-Breath.

the class SignTextCopier method copySignText.

public static boolean copySignText(KeyAction action, IKeybind key) {
    MinecraftClient mc = MinecraftClient.getInstance();
    if (mc.world != null && mc.crosshairTarget != null && mc.crosshairTarget.getType() == HitResult.Type.BLOCK) {
        BlockPos blockPos = ((BlockHitResult) mc.crosshairTarget).getBlockPos();
        BlockState blockState = mc.world.getBlockState(blockPos);
        if (blockState.getBlock() instanceof AbstractSignBlock) {
            BlockEntity blockEntity = mc.world.getBlockEntity(blockPos);
            if (blockEntity instanceof SignBlockEntity) {
                String text = Joiner.on("\n").join(Arrays.stream(((SignBlockEntity) blockEntity).text).map(Text::getString).collect(Collectors.toList()));
                text = StringUtils.strip(text);
                if (!text.isEmpty()) {
                    mc.keyboard.setClipboard(text);
                    InfoUtils.printActionbarMessage("tweakermore.config.copySignTextToClipBoard.sign_copied", blockState.getBlock().getName());
                } else {
                    InfoUtils.printActionbarMessage("tweakermore.config.copySignTextToClipBoard.empty_sign", blockState.getBlock().getName());
                }
                return true;
            }
        }
    }
    InfoUtils.printActionbarMessage("tweakermore.config.copySignTextToClipBoard.no_sign");
    return false;
}
Also used : BlockState(net.minecraft.block.BlockState) SignBlockEntity(net.minecraft.block.entity.SignBlockEntity) MinecraftClient(net.minecraft.client.MinecraftClient) BlockPos(net.minecraft.util.math.BlockPos) Text(net.minecraft.text.Text) BlockHitResult(net.minecraft.util.hit.BlockHitResult) AbstractSignBlock(net.minecraft.block.AbstractSignBlock) BlockEntity(net.minecraft.block.entity.BlockEntity) SignBlockEntity(net.minecraft.block.entity.SignBlockEntity)

Example 33 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project tweakermore by Fallen-Breath.

the class PlacementTweaksMixin method tweakmAutoPickSchematicBlock.

@Inject(method = "tryPlaceBlock", at = @At("HEAD"), remap = false)
private static void tweakmAutoPickSchematicBlock(ClientPlayerInteractionManager controller, ClientPlayerEntity player, ClientWorld world, BlockPos posIn, Direction sideIn, Direction sideRotatedIn, float playerYaw, Vec3d hitVec, Hand hand, PositionUtils.HitPart hitPart, boolean isFirstClick, CallbackInfoReturnable<ActionResult> cir) {
    MinecraftClient mc = MinecraftClient.getInstance();
    if (mc.player != null) {
        if (DataManager.getToolMode() != ToolMode.REBUILD && !Configs.Generic.EASY_PLACE_MODE.getBooleanValue()) {
            if (TweakerMoreConfigs.TWEAKM_AUTO_PICK_SCHEMATIC_BLOCK.getBooleanValue() && EntityUtils.shouldPickBlock(mc.player)) {
                BlockHitResult hitResult = new BlockHitResult(hitVec, sideIn, posIn, false);
                ItemPlacementContext ctx = new ItemPlacementContext(new ItemUsageContext(player, hand, hitResult));
                doSchematicWorldPickBlock(mc, ctx.getBlockPos(), hand);
            }
        }
    }
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) ItemUsageContext(net.minecraft.item.ItemUsageContext) ItemPlacementContext(net.minecraft.item.ItemPlacementContext) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 34 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project KiwiClient by TangyKiwi.

the class MinecraftClientMixin method getWindowTitle.

@Inject(method = "getWindowTitle", at = @At(value = "TAIL"), cancellable = true)
private void getWindowTitle(final CallbackInfoReturnable<String> info) {
    MinecraftClient client = (MinecraftClient) (Object) this;
    String title = KiwiClient.name + " v" + KiwiClient.version;
    ClientPlayNetworkHandler clientPlayNetworkHandler = client.getNetworkHandler();
    if (clientPlayNetworkHandler != null && clientPlayNetworkHandler.getConnection().isOpen()) {
        title += " - ";
        if (client.getServer() != null && !client.getServer().isRemote()) {
            title += I18n.translate("title.singleplayer");
            discordRPC.update("Playing", "Singleplayer");
        } else if (client.isConnectedToRealms()) {
            title += I18n.translate("title.multiplayer.realms");
            discordRPC.update("Playing", "Realms");
        } else if (client.getServer() == null && (client.getCurrentServerEntry() == null || !client.getCurrentServerEntry().isLocal())) {
            title += I18n.translate("title.multiplayer.other");
            discordRPC.update("Playing", client.getCurrentServerEntry().address);
        } else {
            title += I18n.translate("title.multiplayer.lan");
            discordRPC.update("Playing", "LAN Server");
        }
    } else {
        discordRPC.update("Idle", "Main Menu");
    }
    info.setReturnValue(title);
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) ClientPlayNetworkHandler(net.minecraft.client.network.ClientPlayNetworkHandler) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 35 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project KiwiClient by TangyKiwi.

the class KiwiClient method onInitialize.

@Override
public void onInitialize() {
    mc = MinecraftClient.getInstance();
    Utils.mc = mc;
    CustomMatrix.begin(new MatrixStack());
    moduleManager = new ModuleManager();
    moduleManager.init();
    commandManager = new CommandManager();
    commandManager.init();
    discordRPC = new DiscordRP();
    discordRPC.start();
    EChestMemory eChestMemory = new EChestMemory();
    TickRate tickRate = new TickRate();
    eventBus.register(eChestMemory);
    eventBus.register(tickRate);
    eventBus.register(moduleManager);
    ClickGui.clickGui.initWindows();
    FabricLoader.getInstance().getModContainer("kiwiclient").ifPresent(modContainer -> {
        ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("kiwiclient:kiwitweaks"), "resourcepacks/kiwitweaks", modContainer, true);
    });
    UseItemCallback.EVENT.register((player, world, hand) -> {
        MinecraftClient mc = MinecraftClient.getInstance();
        ClientPlayerInteractionManager interactionManager = mc.interactionManager;
        if (mc.mouse.wasRightButtonClicked() && moduleManager.getModule(ArmorSwap.class).isEnabled()) {
            ItemStack stack = player.getMainHandStack();
            int currentItemIndex = player.getInventory().main.indexOf(stack);
            EquipmentSlot equipmentSlot = MobEntity.getPreferredEquipmentSlot(stack);
            int armorIndexSlot = determineIndex(equipmentSlot);
            if (hand == Hand.MAIN_HAND && armorIndexSlot != -1) {
                SoundEvent sound = determineSound(stack.getItem());
                player.playSound(sound, 1.0F, 1.0F);
                interactionManager.clickSlot(player.playerScreenHandler.syncId, armorIndexSlot, currentItemIndex, SlotActionType.SWAP, player);
                return TypedActionResult.success(stack);
            }
        }
        return TypedActionResult.pass(ItemStack.EMPTY);
    });
    KeyBindingHelper.registerKeyBinding(zoomKey);
}
Also used : ClientPlayerInteractionManager(net.minecraft.client.network.ClientPlayerInteractionManager) MatrixStack(net.minecraft.client.util.math.MatrixStack) EquipmentSlot(net.minecraft.entity.EquipmentSlot) ModuleManager(com.tangykiwi.kiwiclient.modules.ModuleManager) EChestMemory(com.tangykiwi.kiwiclient.util.tooltip.EChestMemory) SoundEvent(net.minecraft.sound.SoundEvent) CommandManager(com.tangykiwi.kiwiclient.command.CommandManager) Identifier(net.minecraft.util.Identifier) MinecraftClient(net.minecraft.client.MinecraftClient) ItemStack(net.minecraft.item.ItemStack)

Aggregations

MinecraftClient (net.minecraft.client.MinecraftClient)84 ItemStack (net.minecraft.item.ItemStack)12 Text (net.minecraft.text.Text)7 Identifier (net.minecraft.util.Identifier)7 Inject (org.spongepowered.asm.mixin.injection.Inject)7 BlockPos (net.minecraft.util.math.BlockPos)6 BlockEntity (net.minecraft.block.entity.BlockEntity)5 TextRenderer (net.minecraft.client.font.TextRenderer)5 ClientPlayNetworkHandler (net.minecraft.client.network.ClientPlayNetworkHandler)5 BlockHitResult (net.minecraft.util.hit.BlockHitResult)5 List (java.util.List)4 BlockState (net.minecraft.block.BlockState)4 MatrixStack (net.minecraft.client.util.math.MatrixStack)4 Entity (net.minecraft.entity.Entity)4 PlayerEntity (net.minecraft.entity.player.PlayerEntity)4 NbtCompound (net.minecraft.nbt.NbtCompound)4 AreaIsometricRenderScreen (com.glisco.isometricrenders.client.gui.AreaIsometricRenderScreen)3 IsometricRenderScreen (com.glisco.isometricrenders.client.gui.IsometricRenderScreen)3 GameRenderer (net.minecraft.client.render.GameRenderer)3 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)3