Search in sources :

Example 26 with MinecraftClient

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

the class DisplayUtils method addLoreToHandItem.

public static void addLoreToHandItem(Text text) {
    MinecraftClient mc = MinecraftClient.getInstance();
    assert mc.player != null;
    ItemStack stack = new DisplayUtils(mc.player.getMainHandStack()).addLore(text).get();
    FzmmUtils.giveItem(stack);
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) ItemStack(net.minecraft.item.ItemStack)

Example 27 with MinecraftClient

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

the class FzmmUtils method giveItem.

public static void giveItem(ItemStack stack) {
    MinecraftClient mc = MinecraftClient.getInstance();
    assert mc.player != null;
    if (stack.hasNbt()) {
        NbtCompound tag = stack.getNbt();
        assert tag != null;
        // No funciona cuando se tiene que recibir el paquete del NBT de los blockEntity
        if (getNbtLength(tag) > 1950000) {
            mc.inGameHud.addChatMessage(MessageType.SYSTEM, new TranslatableText("giveItem.exceedLimit").setStyle(Style.EMPTY.withColor(Formatting.RED)), mc.player.getUuid());
            return;
        }
    }
    if (Configs.Generic.GIVE_CLIENT_SIDE.getBooleanValue()) {
        mc.player.equipStack(EquipmentSlot.MAINHAND, stack);
    } else {
        assert mc.interactionManager != null;
        PlayerInventory playerInventory = mc.player.getInventory();
        playerInventory.addPickBlock(stack);
        mc.interactionManager.clickCreativeStack(stack, 36 + playerInventory.selectedSlot);
    }
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) PlayerInventory(net.minecraft.entity.player.PlayerInventory)

Example 28 with MinecraftClient

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

the class FzmmUtils method renameHandItem.

public static void renameHandItem(Text text) {
    MinecraftClient mc = MinecraftClient.getInstance();
    assert mc.player != null;
    ItemStack stack = mc.player.getInventory().getMainHandStack();
    stack.setCustomName(FzmmUtils.disableItalicConfig(text));
    FzmmUtils.giveItem(stack);
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) ItemStack(net.minecraft.item.ItemStack)

Example 29 with MinecraftClient

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

the class EntityMixin method giveDyedArmor.

private void giveDyedArmor(Item item, EquipmentSlot slot, byte slotId) {
    MinecraftClient mc = MinecraftClient.getInstance();
    assert mc.player != null;
    ItemStack stack = item.getDefaultStack();
    NbtCompound display = new NbtCompound();
    int averageColor = getAverageColor(skinPartBuffered);
    if (mc.interactionManager == null) {
        return;
    }
    display.putInt(DyeableItem.COLOR_KEY, averageColor);
    stack.setSubNbt(DyeableItem.DISPLAY_KEY, display);
    skinPartBuffered = new BufferedImage(40, 48, BufferedImage.TYPE_INT_ARGB);
    g = skinPartBuffered.createGraphics();
    mc.player.equipStack(slot, stack);
    mc.interactionManager.clickCreativeStack(stack, slotId);
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) MinecraftClient(net.minecraft.client.MinecraftClient) BufferedImage(java.awt.image.BufferedImage)

Example 30 with MinecraftClient

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

the class GenericCallback method copyItemName.

private boolean copyItemName(boolean copyStyle) {
    MinecraftClient mc = MinecraftClient.getInstance();
    ItemStack stack = InventoryUtils.getFocusedSlot();
    if (stack == null)
        return true;
    Text name = stack.hasCustomName() ? stack.getName() : stack.getItem().getName();
    if (copyStyle) {
        mc.keyboard.setClipboard(Text.Serializer.toJson(name));
    } else {
        mc.keyboard.setClipboard(name.getString());
    }
    return true;
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) Text(net.minecraft.text.Text) 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