Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Listener
- public void onPlayerRightClick(InteractBlockEvent.Secondary event) {
- Optional<ItemStackSnapshot> usedItemOption = event.getCause().getContext().get(EventContextKeys.USED_ITEM);
- Optional<User> userOption = event.getCause().getContext().get(EventContextKeys.OWNER);
- if (usedItemOption.isPresent() && userOption.isPresent()) {
- Optional<Player> playerOption = userOption.get().getPlayer();
- if (playerOption.isPresent()) {
- net.minecraft.item.ItemStack usedItem = ItemStackUtil.toNative(usedItemOption.get().createStack());
- Player player = playerOption.get();
- if (!(usedItem.getTagCompound().getString("pokemonData")).equals("")) {
- PartyStorage party = Pixelmon.storageManager.getParty(player.getUniqueId());
- String tempString = usedItem.getTagCompound().getString("pokemonData");
- NBTTagCompound pokeNBT = new NBTTagCompound();
- try {
- pokeNBT = JsonToNBT.getTagFromJson(tempString);
- } catch (NBTException e) {
- e.printStackTrace();
- }
- Pokemon pokemonToReturn = Pixelmon.pokemonFactory.create(pokeNBT);
- if (party.getTeam().size() < 6) {
- int slotNumber = 0;
- while (party.get(slotNumber) != null) {
- slotNumber++;
- }
- party.set(slotNumber, pokemonToReturn);
- } else {
- player.sendMessage(Text.of("Your Party is Full!"));
- }
- player.sendMessage(Text.of(usedItem.getTagCompound().getString("pokemonData")));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement