Jakllp / MyPet

This is not the main project - Please visit https://github.com/MyPetORG/MyPet
https://www.spigotmc.org/resources/mypet.12725/
GNU Lesser General Public License v3.0
14 stars 8 forks source link

Bug: Axolotlcide #28

Closed Jakllp closed 3 years ago

Jakllp commented 3 years ago

Pet-Axolotls let normal Axolotls despawn when they get too close to them

This seems related to some Vanilla behaviour of Axolotls

[02:38:11 ERROR]: TIMING_STACK_CORRUPTION - Look above this for any errors and report this to Paper unless it has a plugin in the stack trace (TimingIdentifier{id=Minecraft:## Sensor - adultsensor (Default rate: 20)} did not stopTiming)
[02:38:11 ERROR]: Entity threw exception at world:105.25213166908298,68.0,-185.16337918041418
java.lang.ClassCastException: class de.Keyle.MyPet.compat.v1_17_R1.entity.types.EntityMyAxolotl cannot be cast to class net.minecraft.world.entity.EntityAgeable (de.Keyle.MyPet.compat.v1_17_R1.entity.types.EntityMyAxolotl is in unnamed module of loader 'MyPet-3.12-dev5.1.jar' @1c808c36; net.minecraft.world.entity.EntityAgeable is in unnamed module of loader 'app')
    at net.minecraft.world.entity.ai.sensing.SensorAdult.lambda$setNearestVisibleAdult$2(SensorAdult.java:35) ~[patched_1.17.1.jar:git-Paper-209]
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[?:?]
    at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) ~[?:?]
    at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1602) ~[?:?]
    at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129) ~[?:?]
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502) ~[?:?]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488) ~[?:?]
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[?:?]
    at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150) ~[?:?]
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
    at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647) ~[?:?]
    at net.minecraft.world.entity.ai.sensing.SensorAdult.setNearestVisibleAdult(SensorAdult.java:37) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.world.entity.ai.sensing.SensorAdult.lambda$doTick$0(SensorAdult.java:28) ~[patched_1.17.1.jar:git-Paper-209]
    at java.util.Optional.ifPresent(Optional.java:178) ~[?:?]
    at net.minecraft.world.entity.ai.sensing.SensorAdult.a(SensorAdult.java:27) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.world.entity.ai.sensing.SensorAdult.a(SensorAdult.java:17) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.world.entity.ai.sensing.Sensor.b(Sensor.java:51) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.world.entity.ai.BehaviorController.c(BehaviorController.java:476) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.world.entity.ai.BehaviorController.a(BehaviorController.java:469) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.world.entity.animal.axolotl.Axolotl.mobTick(Axolotl.java:281) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.world.entity.EntityInsentient.doTick(EntityInsentient.java:845) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.world.entity.EntityLiving.movementTick(EntityLiving.java:3155) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.world.entity.EntityInsentient.movementTick(EntityInsentient.java:625) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.world.entity.EntityAgeable.movementTick(EntityAgeable.java:154) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.world.entity.animal.EntityAnimal.movementTick(EntityAnimal.java:59) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.world.entity.EntityLiving.tick(EntityLiving.java:2881) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.world.entity.EntityInsentient.tick(EntityInsentient.java:393) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.server.level.WorldServer.entityJoinedWorld(WorldServer.java:903) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.world.level.World.a(World.java:869) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.server.level.WorldServer.lambda$tick$5(WorldServer.java:600) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.world.level.entity.EntityTickList.a(EntityTickList.java:54) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.server.level.WorldServer.doTick(WorldServer.java:581) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1553) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:479) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1406) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1188) ~[patched_1.17.1.jar:git-Paper-209]
    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[patched_1.17.1.jar:git-Paper-209]
    at java.lang.Thread.run(Thread.java:831) [?:?]
CJBlakey commented 3 years ago

changing EntityMyPet to extend AgeableMob fixes this issue but breaks the baby system. Could possibly workaround this by reworking the baby system to have another class for EntityMyPetBaby that extends mob with EntityMyPet to extend AgeableMob

CJBlakey commented 3 years ago
c   net/minecraft/world/entity/AgeableMob   net/minecraft/world/entity/EntityAgeable
    m   (Lnet/minecraft/nbt/CompoundTag;)V  addAdditionalSaveData   saveData
    m   ()V ageBoundaryReached  n
    m   (I)V    ageUp   setAge
    m   (IZ)V   ageUp   setAge
    m   ()V aiStep  movementTick
    m   ()V defineSynchedData   initDatawatcher
    m   (Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/MobSpawnType;Lnet/minecraft/world/entity/SpawnGroupData;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/world/entity/SpawnGroupData; finalizeSpawn   prepare
    m   (Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/AgeableMob;)Lnet/minecraft/world/entity/AgeableMob;    getBreedOffspring   createChild
    m   (Lnet/minecraft/network/syncher/EntityDataAccessor;)V   onSyncedDataUpdated a
    m   (Lnet/minecraft/nbt/CompoundTag;)V  readAdditionalSaveData  loadData
    m   (I)V    setAge  setAgeRaw
    f   I   BABY_START_AGE  b
    f   Lnet/minecraft/network/syncher/EntityDataAccessor;  DATA_BABY_ID    bT
    f   I   FORCED_AGE_PARTICLE_TICKS   bU
    f   I   age c
    f   I   forcedAge   d
    f   I   forcedAgeTimer  e

setAge and ageLock are of interest. Need to experiment with the values a bit and put some thought into mobs with various stages of growth. This will require us to rework the current way that baby pets are implemented, but seems to be the correct way to achieve the desired result. Will not be working on this for the next 14 hours due to work commitments, if anyone wants to take a crack at it between now and then feel free to. I'll give it a shot tomorrow night

Jakllp commented 3 years ago

Done in https://github.com/Jakllp/MyPet/commit/2b468585fbfb62328e27635b2aaac048d6483d2a

Now using age -1 and 1 (baby, not baby) in the inbuild age-system