Skript: last spawned entity does not always return

Created on 21 Jun 2020  路  8Comments  路  Source: SkriptLang/Skript

Description

last spawned entity does not always return, it'll return none in some cases

Steps to Reproduce

simple code:

spawn a villager at location of {_p}
set {_villager} to last spawned entity

sometimes, with about 30% chance, {_villager} will be none while the villager did get spawned

Expected Behavior


I expect it to return villager entity at ALL times

Errors / Screenshots

None

Server Information

  • Server version/platform: 1.12.2 paper
  • Skript version: 2.5 alpha3

Additional Context

bug completed medium

Most helpful comment

if anyone runs into the same issue before it is fixed, here's a temporary skript-mirror workaround:

import:
    org.bukkit.entity.EntityType
function entityType(type: string) :: string:
    switch {_type}:
        case "ender dragon":
            return "ENDER_DRAGON"
        case "TNT":
            return "PRIMED_TNT"
        case "ender crystal":
            return "ENDER_CRYSTAL"
        case "armor stand":
            return "ARMOR_STAND"
        case "dropped item":
            return "DROPPED_ITEM"
    return {_type}
expression (spawn|summon) [custom] %entitytypes% at %location%:
    get:
        return (expression 2).getWorld().spawnEntity((expression 2), EntityType.valueOf((entityType("%expression-1%")).toUpperCase()))

All 8 comments

I can not replicate this issue:

command /test:
    trigger:
        loop 20 times:
            spawn a villager at spawn of world "world"
            set {_v} to last spawned villager
            send "Villlager: &a%{_v}% &7UUID: &b%uuid of {_v}%" to console
        kill all villagers

Screen Shot 2020-06-21 at 4 35 00 AM

I can not replicate this issue:

command /test:
    trigger:
        loop 20 times:
            spawn a villager at spawn of world "world"
            set {_v} to last spawned villager
            send "Villlager: &a%{_v}% &7UUID: &b%uuid of {_v}%" to console
        kill all villagers

Screen Shot 2020-06-21 at 4 35 00 AM

oh you can, check the output more, some UUIDS are the same, you aren't deleting {_v}

Hmm, not sure then, Ill mark it as a bug.

I think it should be of higher priority than just low, because many people in their scripts that work with entities use "last spawned entity" and with it being unpredictable, it can really destroy their logic (like it did in mine)

changed

if anyone runs into the same issue before it is fixed, here's a temporary skript-mirror workaround:

import:
    org.bukkit.entity.EntityType
function entityType(type: string) :: string:
    switch {_type}:
        case "ender dragon":
            return "ENDER_DRAGON"
        case "TNT":
            return "PRIMED_TNT"
        case "ender crystal":
            return "ENDER_CRYSTAL"
        case "armor stand":
            return "ARMOR_STAND"
        case "dropped item":
            return "DROPPED_ITEM"
    return {_type}
expression (spawn|summon) [custom] %entitytypes% at %location%:
    get:
        return (expression 2).getWorld().spawnEntity((expression 2), EntityType.valueOf((entityType("%expression-1%")).toUpperCase()))

This issue does not appear to affect newer versions at all, from what I can see.

While it might still be happening, it has not appeared in over a dozen tests on either my local or remote servers. It seems to be limited to outdated MC versions from what I can tell (I'm going to test 1.13 through 1.15 today)

EDIT: I've tested a bunch of versions. It seems to be absolutely fine in 1.14+ :)

1.12.2 (issue present - there are duplicate indices):
image

1.16.1 (issue presumably absent - no duplicate indices):
image

So turns out this was just a silly little typo in VillagerData.
Its always those teeny tiny things right!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cyanide43 picture cyanide43  路  4Comments

TrademarkTM picture TrademarkTM  路  4Comments

TheClassic36 picture TheClassic36  路  3Comments

ghost picture ghost  路  3Comments

Romitou picture Romitou  路  3Comments