Error with getting a ItemStack from pixelmon inside a GUI!

As the title says i have a problem with using some of the API from pixelmon inside my sponge plugin, I can use events etc without errors, but I can’t use the items etc. Im getting errors from the imports.

package mc.hund35.test.guis; <— error as soon I import some of the classes from pixelmon

import java.util.ArrayList;
import java.util.List;
import org.spongepowered.api.Game;
import org.spongepowered.api.GameRegistry;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.inventory.Inventory;
import org.spongepowered.api.item.inventory.InventoryArchetype;
import org.spongepowered.api.item.inventory.InventoryArchetypes;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.item.inventory.ItemStackBuilderPopulators;
import org.spongepowered.api.item.inventory.entity.Hotbar;
import org.spongepowered.api.item.inventory.transaction.InventoryTransactionResult;
import org.spongepowered.api.item.inventory.type.GridInventory;
import org.spongepowered.api.item.inventory.type.Inventory2D;
import org.spongepowered.api.item.inventory.type.InventoryColumn;
import org.spongepowered.api.item.inventory.type.InventoryRow;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.translation.FixedTranslation;

import com.pixelmonmod.pixelmon.config.PixelmonItemsBadges; <---- as soon I import this or other item classes.

import mc.hund35.test.test;
import mc.hund35.test.config.load;

public class badges {

    static Inventory inv;
	public static Inventory GUI(Player p)
	 ItemStack badge1 = ItemStack.Builder.itemType(PixelmonItemsBadges.balanceBadge).build();

inv = Inventory.builder().property(InventoryTitle.PROPERTY_NAME, new InventoryTitle(Text.of("Test gui"))).property(InventoryDimension.PROPERTY_NAM, new InventoryDimension(9,2)).build(test.getInstance());

inv.query(InventoryRow.class).query(new SlotIndex(0)).set(this.badge1); 

		     return inv;

Well, what are the errors?

1 Like

“the type net.minecraft.item.Item cannot be resolved” - the problem seems to be I can’t find the ItemStack class (net.minecraft.item.item) / the net.minecraft packages. I remember bukkit’ had something like that implemented (yes, I know sponge and bukkit are coded different)

Set it up to use the forge workspace.

Well it fixed one problem, but lead to another one I was afford will happen (It can only accept sponge own ItemStack method). It seems I’ll have to create the gui with forge API instead :confused:

(ItemStack) stack

Well, pixelmonitems can still not be casted to ItemStack.

Why not?

Thanks, (ItemStack) stack got me to realized i could do it with the ItemType to fix it, seems my ItemStack was built wrong. I think this could maybe be useful, if other has the same problem:
ItemStack badge1 = ItemStack.builder().itemType((ItemType)PixelmonItemsBadges.balanceBadge).quantity(1).build();