I trying to cast EntityPlayerMP to Player, using Pixelmon event, but show this error:
Libs:
Sponge: 7.4.0
Forge: forge-1.12.2-14.23.5.2860
package pkbr.battlepass.listeners;
import com.pixelmonmod.pixelmon.api.enums.ReceiveType;
import com.pixelmonmod.pixelmon.api.events.PixelmonReceivedEvent;
import com.pixelmonmod.pixelmon.api.pokemon.Pokemon;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import pkbr.battlepass.Main;
import pkbr.battlepass.utils.PlayerData;
public class PokemonCapture {
@SubscribeEvent
public void onPokemonReceived(final PixelmonReceivedEvent e) {
if (e.receiveType == ReceiveType.PokeBall) {
final PlayerData playerData = Main.getPlayerCache().get((Player) e.player); //the error its here
final Pokemon pokemon = e.pokemon;
if (pokemon.isShiny()) {
playerData.setExp(playerData.getExp() + 100.0);
} else if (pokemon.isLegendary()) {
playerData.setExp(playerData.getExp() + 700.0);
}
}
}
}