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