Skip to content
This repository was archived by the owner on Jan 5, 2025. It is now read-only.

Getting Started

efekos edited this page Jan 25, 2024 · 1 revision

This page will teach how to start using ItemContent.

Adding the dependency

Maven

You need to add the following repository and dependency to your project if you didn't before.

<repository>
   <id>jitpack.io</id>
   <url>https://jitpack.io</url>
</repository>

<dependency>
   <groupId>com.github.efekos</groupId>
   <artifactId>ItemContent</artifactId>
   <version>master-SNAPSHOT</version> // master branch is for Minecraft 1.20.2. Use other branches as version for older/newer versions of Minecraft.
</dependency>

Gradle

You need to add the following repository and dependency to your project if you didn't before.

repositories {
   mavenCentral()
   maven { url 'https://jitpack.io' }
}

dependencies {
   implementation 'com.github.efekos:ItemContent:master-SNAPSHOT' // master branch is for Minecraft 1.20.2. Use other branches as version for older/newer versions of Minecraft.
}

Usage

As you might know, when you want to add an hover event using BaseComponents of BungeeAPI, you need a HoverEvent object and use it on BaseComponent#setHoverEvent(HoverEvent) method. This HoverEvent object has a constructor with signature HoverEvent#HoverEvent(Action,Content...). All you need to do is choose SHOW_ITEM as action type, and add an ItemContent. Here is a basic example of this:

TextComponent component;
ItemStack item;
        
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM,ItemContent.from(item)));

ItemContent#from(ItemStack,Integer) method is used to define slots inside item containers (such as a shulker box), so you don't have to use that. The other method (ItemContent#from(ItemStack)) is the main method. It generates an ItemContent from the ItemStack given.

And that's it! I hope this page was helpful. Have a nice day with your cool items in chat!

Clone this wiki locally