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());
}
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;
}
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);
}
}
}
}
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);
}
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);
}
Aggregations