ohowe1 / SpectatorModeRewrite

Minecraft plugin that allows players to go into spectator mode but enables admins to prevent features of it.
https://www.spigotmc.org/resources/smp-spectator-mode-1-16-support.77267/
MIT License
17 stars 10 forks source link

Some mobs won’t despawn after uses of /s #15

Closed ohowe1 closed 4 years ago

ohowe1 commented 4 years ago

Describe the bug A clear and concise description of what the bug is. Some mobs won’t despawn after player uses /s

To Reproduce Steps to reproduce the behavior:

  1. /s
  2. /s again
  3. some of the mobs may not despawn

Minecraft version 1.16.3

Console error none

Expected behavior After the player gets back into survival mode the mobs will despawn normally

Karloss0x commented 4 years ago

Well i'm not installing that plugin on my server unless it's repaired. But i can tell you everything i knew about that problem.

So when you use /s it makes mobs not to despawn. It's becouse all mobs gets [nbt={PersistenceRequired:1b}] (idk if they gets it as they spawn or after using /s ). Always when i got to newly spawned mob and used /data get (entity) it showed his persistence 1 . It works on every(what i know every) hostile mob and underwater mobs.

So what i think it's needed to be done is to change that nbt to 0 after exiting /s... But make it so it won't change [nbt={PersistenceRequired:1b}] to mobs which get that by using name tag or holding item. Iam really new to programming but what i think could help is to tag all the mobs(not selecting mobs with already having persistence 1) when using /s which get [nbt={PersistenceRequired:1b}] and after exiting /s change it back to [nbt={PersistenceRequired:0b}]

Some of my logs

Data of mob when SMP was active `INFO]: [CHAT] [23:49:58] ...get entity<--[HERE] [23:50:05] [main/INFO]: [CHAT] [23:50:05] Zombie has the following entity data: {Paper.SpawnReason: "NATURAL", DeathTime: 0s, Bukkit.updateLevel: 2, LeftHanded: 0b, OnGround: 1b, AbsorptionAmount: 0.0f, IsBaby: 0b, Attributes: [{Name: "minecraft:generic.knockback_resistance", Modifiers: [{Name: "Random spawn bonus", Amount: 0.03636132108364637d, Operation: 0, UUID: [I; -1163077348, -128692274, -1223860204, 1910798811]}], Base: 0.0d}, {Name: "minecraft:generic.movement_speed", Base: 0.23000000417232513d}, {Name: "minecraft:generic.max_health", Base: 20.0d}, {Name: "minecraft:generic.follow_range", Modifiers: [{Name: "Random spawn bonus", Amount: 0.04050568929243499d, Operation: 1, UUID: [I; 226668665, 1527204574, -1790905154, 457888333]}], Base: 35.0d}, {Name: "minecraft:zombie.spawn_reinforcements", Base: 0.09940933846906672d}], Invulnerable: 0b, Brain: {memories: {}}, Paper.Origin: [-238.5d, 16.0d, 540.5d], Bukkit.Aware: 1b, HandDropChances: [0.085f, 0.085f], Rotation: [178.36017f, 0.0f], ArmorDropChances: [0.085f, 0.085f, 0.085f, 0.085f], HurtByTimestamp: 0, CanBreakDoors: 1b, WorldUUIDMost: 5540158239057003997L, InWaterTime: -1, ArmorItems: [{}, {}, {}, {}], Air: 300s, HandItems: [{}, {}], UUID: [I; -1286566652, -581091212, -1082313815, 352825367], Spigot.ticksLived: 463, DrownedConversionTime: -1, FallDistance: 0.0f, WorldUUIDLeast: -6728740248323109766L, Motion: [0.0d, -0.0784000015258789d, 0.0d], Pos: [-242.50357260417977d, 18.0d, 536.8162078831737d], Fire: -1s, CanPickUpLoot: 0b, Health: 20.0f, HurtTime: 0s, FallFlying: 0b, PersistenceRequired: 1b, PortalCooldown: 0, Paper.ShouldBurnInDay:1b}`
Data of mob when smp wasn't active [CHAT] [00:08:17] Set own game mode to Spectator Mode [00:08:31] [main/INFO]: [CHAT] [00:08:31] Zombie has the following entity data: {Paper.SpawnReason: "NATURAL", DeathTime: 0s, Bukkit.updateLevel: 2, LeftHanded: 0b, OnGround: 1b, AbsorptionAmount: 0.0f, IsBaby: 0b, Attributes: [{Name: "minecraft:generic.knockback_resistance", Modifiers: [{Name: "Random spawn bonus", Amount: 0.029347070356939748d, Operation: 0, UUID: [I; -199214717, 878987475, -1360390221, 1970015198]}], Base: 0.0d}, {Name: "minecraft:generic.attack_damage", Base: 3.0d}, {Name: "minecraft:generic.movement_speed", Base: 0.23000000417232513d}, {Name: "minecraft:generic.max_health", Base: 20.0d}, {Name: "minecraft:generic.follow_range", Modifiers: [{Name: "Random spawn bonus", Amount: -0.04899566562761162d, Operation: 1, UUID: [I; 1337662829, 1380992392, -1626008649, -1591468074]}], Base: 35.0d}, {Name: "minecraft:zombie.spawn_reinforcements", Base: 0.09382664602122565d}], Invulnerable: 0b, Brain: {memories: {}}, Paper.Origin: [-273.5d, 48.0d, 591.5d], Bukkit.Aware: 1b, HandDropChances: [0.085f, 0.085f], Rotation: [89.65526f, 0.0f], ArmorDropChances: [0.085f, 0.085f, 0.085f, 0.085f], HurtByTimestamp: 0, CanBreakDoors: 0b, WorldUUIDMost: 5540158239057003997L, InWaterTime: -1, ArmorItems: [{}, {}, {}, {}], Air: 300s, HandItems: [{id: "minecraft:iron_sword", tag: {Damage: 0}, Count: 1b}, {}], UUID: [I; 546064478, -1879488029, -1161067629, 1705419454], Spigot.ticksLived: 442, DrownedConversionTime: -1, FallDistance: 0.0f, WorldUUIDLeast: -6728740248323109766L, Motion: [0.0d, -0.0784000015258789d, 0.0d], Pos: [-275.69999998807907d, 48.0d, 591.4891701025883d], Fire: -1s, CanPickUpLoot: 1b, Health: 20.0f, HurtTime: 0s, FallFlying: 0b, PersistenceRequired: 0b, PortalCooldown: 0, Paper.ShouldBurnInDay: 1b}
some screenshots ![2020-10-21_22 00 46](https://user-images.githubusercontent.com/73352792/97023741-3b3a9d80-1556-11eb-8e3e-301d59ee5e50.png) ![cave](https://user-images.githubusercontent.com/73352792/97023749-3d9cf780-1556-11eb-9f03-21355a4d3d2d.png) ![cave2](https://user-images.githubusercontent.com/73352792/97023756-3fff5180-1556-11eb-96f6-874a82f0f9d2.png) ![underwater](https://user-images.githubusercontent.com/73352792/97023761-4261ab80-1556-11eb-9e8a-f65ae4cbb555.png)
ohowe1 commented 4 years ago

Thanks. When the player executes /s, it puts all the mobs into persistence 1 that are not already in persistence 1 and saves there uuids. When they un /s it takes all the uuids and changes the persistence to 0. A problem with this is that I'm pretty sure that when the server restarts all the uuids of the mobs change (I could be wrong about this). I think one of the only ways to fix this would be to persistence 0 all the mobs with the uuids as the server is shutting down, with players still in spectator mode. Would that be an ok compromise?

Edit: This seems not to be the case and is being caused by something else

ohowe1 commented 4 years ago

Well i'm not installing that plugin on my server unless it's repaired. But i can tell you everything i knew about that problem.

So when you use /s it makes mobs not to despawn. It's becouse all mobs gets [nbt={PersistenceRequired:1b}] (idk if they gets it as they spawn or after using /s ). Always when i got to newly spawned mob and used /data get (entity) it showed his persistence 1 . It works on every(what i know every) hostile mob and underwater mobs.

So what i think it's needed to be done is to change that nbt to 0 after exiting /s... But make it so it won't change [nbt={PersistenceRequired:1b}] to mobs which get that by using name tag or holding item. Iam really new to programming but what i think could help is to tag all the mobs(not selecting mobs with already having persistence 1) when using /s which get [nbt={PersistenceRequired:1b}] and after exiting /s change it back to [nbt={PersistenceRequired:0b}]

Some of my logs Data of mob when SMP was active INFO]: [CHAT] [23:49:58] ...get entity<--[HERE] [23:50:05] [main/INFO]: [CHAT] [23:50:05] Zombie has the following entity data: {Paper.SpawnReason: "NATURAL", DeathTime: 0s, Bukkit.updateLevel: 2, LeftHanded: 0b, OnGround: 1b, AbsorptionAmount: 0.0f, IsBaby: 0b, Attributes: [{Name: "minecraft:generic.knockback_resistance", Modifiers: [{Name: "Random spawn bonus", Amount: 0.03636132108364637d, Operation: 0, UUID: [I; -1163077348, -128692274, -1223860204, 1910798811]}], Base: 0.0d}, {Name: "minecraft:generic.movement_speed", Base: 0.23000000417232513d}, {Name: "minecraft:generic.max_health", Base: 20.0d}, {Name: "minecraft:generic.follow_range", Modifiers: [{Name: "Random spawn bonus", Amount: 0.04050568929243499d, Operation: 1, UUID: [I; 226668665, 1527204574, -1790905154, 457888333]}], Base: 35.0d}, {Name: "minecraft:zombie.spawn_reinforcements", Base: 0.09940933846906672d}], Invulnerable: 0b, Brain: {memories: {}}, Paper.Origin: [-238.5d, 16.0d, 540.5d], Bukkit.Aware: 1b, HandDropChances: [0.085f, 0.085f], Rotation: [178.36017f, 0.0f], ArmorDropChances: [0.085f, 0.085f, 0.085f, 0.085f], HurtByTimestamp: 0, CanBreakDoors: 1b, WorldUUIDMost: 5540158239057003997L, InWaterTime: -1, ArmorItems: [{}, {}, {}, {}], Air: 300s, HandItems: [{}, {}], UUID: [I; -1286566652, -581091212, -1082313815, 352825367], Spigot.ticksLived: 463, DrownedConversionTime: -1, FallDistance: 0.0f, WorldUUIDLeast: -6728740248323109766L, Motion: [0.0d, -0.0784000015258789d, 0.0d], Pos: [-242.50357260417977d, 18.0d, 536.8162078831737d], Fire: -1s, CanPickUpLoot: 0b, Health: 20.0f, HurtTime: 0s, FallFlying: 0b, PersistenceRequired: 1b, PortalCooldown: 0, Paper.ShouldBurnInDay:1b} Data of mob when smp wasn't active [CHAT] [00:08:17] Set own game mode to Spectator Mode [00:08:31] [main/INFO]: [CHAT] [00:08:31] Zombie has the following entity data: {Paper.SpawnReason: "NATURAL", DeathTime: 0s, Bukkit.updateLevel: 2, LeftHanded: 0b, OnGround: 1b, AbsorptionAmount: 0.0f, IsBaby: 0b, Attributes: [{Name: "minecraft:generic.knockback_resistance", Modifiers: [{Name: "Random spawn bonus", Amount: 0.029347070356939748d, Operation: 0, UUID: [I; -199214717, 878987475, -1360390221, 1970015198]}], Base: 0.0d}, {Name: "minecraft:generic.attack_damage", Base: 3.0d}, {Name: "minecraft:generic.movement_speed", Base: 0.23000000417232513d}, {Name: "minecraft:generic.max_health", Base: 20.0d}, {Name: "minecraft:generic.follow_range", Modifiers: [{Name: "Random spawn bonus", Amount: -0.04899566562761162d, Operation: 1, UUID: [I; 1337662829, 1380992392, -1626008649, -1591468074]}], Base: 35.0d}, {Name: "minecraft:zombie.spawn_reinforcements", Base: 0.09382664602122565d}], Invulnerable: 0b, Brain: {memories: {}}, Paper.Origin: [-273.5d, 48.0d, 591.5d], Bukkit.Aware: 1b, HandDropChances: [0.085f, 0.085f], Rotation: [89.65526f, 0.0f], ArmorDropChances: [0.085f, 0.085f, 0.085f, 0.085f], HurtByTimestamp: 0, CanBreakDoors: 0b, WorldUUIDMost: 5540158239057003997L, InWaterTime: -1, ArmorItems: [{}, {}, {}, {}], Air: 300s, HandItems: [{id: "minecraft:iron_sword", tag: {Damage: 0}, Count: 1b}, {}], UUID: [I; 546064478, -1879488029, -1161067629, 1705419454], Spigot.ticksLived: 442, DrownedConversionTime: -1, FallDistance: 0.0f, WorldUUIDLeast: -6728740248323109766L, Motion: [0.0d, -0.0784000015258789d, 0.0d], Pos: [-275.69999998807907d, 48.0d, 591.4891701025883d], Fire: -1s, CanPickUpLoot: 1b, Health: 20.0f, HurtTime: 0s, FallFlying: 0b, PersistenceRequired: 0b, PortalCooldown: 0, Paper.ShouldBurnInDay: 1b} some screenshots 2020-10-21_22 00 46 cave cave2 underwater

I have found the problem to the bug and have fixed it. Expect an update soon. Thanks Edit: Update pushed to spigot. Be sure to read the update description