Pokecube AIO

Pokecube AIO

498k Downloads

Changing Starter Levels and Starter Moves

bassistracer opened this issue ยท 1 comments

commented

Was told to put my idea here.

The ability to change starter levels (and beginning moves) via data packs or an add-on would be really good -- namely for people who don't wanna start with Tackle/Scratch/Pound and Leer/Tail Whip/Growl all the time.
Could be good if someone just wants their fully evolved starters already, or, taking inspiration from Pokemon Colosseum, having level 25 starters that have a couple of TM moves. Like the protagonist there has an Umbreon with Secret Power and Taunt for example.

Thanks for reading!

commented

Hmm this can presently be done with a java addon via intercepting the StarterEvent.Pick event and then implementing such code there.

This is where the starter code is presently handled:

// Fire pre event to deny starters from being processed.
final StarterEvent.Pre pre = new StarterEvent.Pre(player);
MinecraftForge.EVENT_BUS.post(pre);
if (pre.isCanceled()) return;
final String entryName = this.data.getString("N");
final PokedexEntry entry = Database.getEntry(entryName);
// Did they also get contributor stuff.
final List<ItemStack> items = Lists.newArrayList();
// Copy main list from database.
for (final ItemStack stack : Database.starterPack)
items.add(stack.copy());
// No Custom Starter. just gets this
final ItemStack pokemobItemstack = PokecubeSerializer.getInstance().starter(entry, player);
items.add(pokemobItemstack);
// Fire pick event to add new starters or items
final StarterEvent.Pick pick = new StarterEvent.Pick(player, items, entry);
MinecraftForge.EVENT_BUS.post(pick);
/**
* If canceled, assume items were not needed, or canceller handled
* giving them.
*/
if (pick.isCanceled()) return;
/** Update itemlist from the pick event. */
items.clear();
items.addAll(pick.starterPack);
for (final ItemStack e : items)
{
if (e.isEmpty()) continue;
/**
* Run this before tools.give, as that invalidates the
* itemstack.
*/
if (PokecubeManager.isFilled(e))
{
final IPokemob pokemob = PokecubeManager.itemToPokemob(e, player.getLevel());
/** First pokemob advancement on getting starter. */
if (pokemob != null && pokemob.getPokedexEntry() == entry) StatsCollector.addCapture(pokemob);
}
Tools.giveItem(player, e);
}
/** Set starter status to prevent player getting more starters. */
PokecubeSerializer.getInstance().setHasStarter(player);
PokecubeSerializer.getInstance().save();
// Send Packt to client to notifiy about having a starter now.
final PacketChoose packet = new PacketChoose(PacketChoose.OPENGUI);
packet.data.putBoolean("C", false);
packet.data.putBoolean("H", true);
PokecubeCore.packets.sendTo(packet, player);

Presently after making the itemstack containing the pokemob, it puts it into a list, and fires a StarterEvent.Pick event. The starterPack list in this event only contains the pokecube containing the pokemob. You can listen for this event, and adjust the nbt of that item accordingly (or remove the item and add your custom made pokemob)

Here is the default code for generating the pokemob's item:

public ItemStack starter(final PokedexEntry entry, final Player owner)
{
final Level worldObj = owner.getLevel();
final IPokemob entity = PokemobCaps.getPokemobFor(PokecubeCore.createPokemob(entry, worldObj));
if (entity != null)
{
// Initialise position first for spsawn init check
entity.getEntity().moveTo(owner.position());
entity.setForSpawn(Tools.levelToXp(entity.getExperienceMode(), 5));
entity.setHealth(entity.getMaxHealth());
entity.setOwner(owner.getUUID());
entity.setPokecube(new ItemStack(PokecubeItems.getFilledCube(PokecubeBehaviour.DEFAULTCUBE)));
final ItemStack item = PokecubeManager.pokemobToItem(entity);
PokecubeManager.heal(item, owner.getLevel());
entity.getEntity().discard();
return item;
}
return ItemStack.EMPTY;
}

There you have access to the pokemob itself before it puts it into the cube, so you can adjust it however you want.

If you need a different gui instead, that would need a client-side addon, and currently doesn't have a good event to replace, I can add one of those though.