Type: Null pokemon creation bug
Summary
Trying to create a Pokemon by species name for Type: Null will result in a random one
Steps to reproduce
The following java code will do the trick.
Note: There are logging messages from 3 consecutive runs of the written code in the Relevant logs section.
public static void foo(String speciesName){
if (speciesName.equals("typenull")) {
Logger.error("Trying to create a species with the name: " + speciesName);
}
Species species = PokemonSpecies.INSTANCE.getByName(speciesName);
if (species == null) {
return null;
}
if (speciesName.equals("typenull")) {
Logger.error("Got the species with the resource identifier: " + species.resourceIdentifier + " and name: " + species.getName());
}
Pokemon pokemon = species.create(1);
if (speciesName.equals("typenull")) {
Logger.error("The resulting pokemon display name is: " + pokemon.getDisplayName().getString() +
" with the species resource identifier: " + pokemon.getSpecies().resourceIdentifier + " and name: " + pokemon.getSpecies().getName());
pokemon.setSpecies(species);
}
}
What is the current bug behavior?
Currently you will get a random pokemon back.
What is the expected correct behavior?
To receive a Pokemon with the species resource identifier cobblemon:typenull everytime the Pokemon pokemon = species.create(1); line is executed while having speciesName="typenull.
Cobblemon Version and Mod Loader
Fabric, cobblemon version 1.6.1
Mods used besides Cobblemon
N/A
Relevant logs, screenshots and/or videos
First run:
Trying to create a species with the name: typenull
Got the species with the resource identifier: cobblemon:typenull and name: Type: Null
The resulting pokemon display name is: Mudbray with the species resource identifier: cobblemon:mudbray and name: Mudbray
Second run:
Trying to create a species with the name: typenull
Got the species with the resource identifier: cobblemon:typenull and name: Type: Null
The resulting pokemon display name is: Beldum with the species resource identifier: cobblemon:beldum and name: Beldum
Third run:
Trying to create a species with the name: typenull
Got the species with the resource identifier: cobblemon:typenull and name: Type: Null
The resulting pokemon display name is: Garchomp with the species resource identifier: cobblemon:garchomp and name: Garchomp
Additional Information
- If it helps,
772=typenullis present inPokemonSpecies.INSTANCE.getSpeciesInNamespace("cobblemon"); - The responsible line should be
Pokemon pokemon = species.create(1);as the species resulting fromSpecies species = PokemonSpecies.INSTANCE.getByName(speciesName)seems to be correct.
Edited by Mădălin Coman