Class ExperienceWriteBackTests

java.lang.Object
com.pixelmonmod.pixelmon.api.test.impl.mechanics.ExperienceWriteBackTests

public class ExperienceWriteBackTests extends Object
Provers for the npc battle exp reversion bug where a mon comes out of the battle with only the last kills exp payout.

wrapper and original share a UUID, battle send ins bind thev live entity to the wrapper, and the SYNC_EXP DataSync resolves entities by world UUID lookup and pokes entity.getPokemon().experience directly. So writeChangesToOriginalPokemon calling setLevel (which zeroes exp) on the original zeroes the wrapper too, and the setExperience(getExperience()) restore reads back the zero. The two entity tests fail without the fixes, the control passes either way.

  • Constructor Details

    • ExperienceWriteBackTests

      public ExperienceWriteBackTests()
  • Method Details

    • testExpSurvivesWriteBackWithoutEntity

      public static CompletableFuture<TestResult> testExpSurvivesWriteBackWithoutEntity(BattleTestHelper helper)
      Control, no entity in the world. The write back is fine when no wrapper bound entity exists, which is why the exisitng exp tests never caught this. Passes before and after the fixes, if this fails the other two arent telling you anything.
    • testExpSurvivesWriteBackWithBattleSpawnedEntity

      public static CompletableFuture<TestResult> testExpSurvivesWriteBackWithBattleSpawnedEntity(BattleTestHelper helper)
      Same write back but with the wrappers entity alive in the world, like a real battle after the lead gets sent out. Unfixed, the original ends the battle with 0 exp.
    • testSettingOriginalExpDoesNotClobberWrapper

      public static CompletableFuture<TestResult> testSettingOriginalExpDoesNotClobberWrapper(BattleTestHelper helper)
      DataSync channel by itself. Setting the ORIGINALs exp should never move the WRAPPERs exp.