Error of Pikachu's Snippets [Spawner]

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

KingAdmin_YT

Member
May 16, 2018
44
0
6
25
Code:
import:
    org.bukkit.inventory.meta.BlockStateMeta
    org.bukkit.entity.EntityType
    org.bukkit.block.CreatureSpawner
    org.bukkit.inventory.ItemStack

function spawner(entity: string) :: item:
  set {_enum} to try {EntityType}.valueOf({_entity}.toUpperCase())
  set {_spawner} to mob spawner
  set {_spawner} to {_spawner}.getRandom()
  set {_blockStateMeta} to {_spawner}.getItemMeta() as {BlockStateMeta}
  set {_creatureSpawner} to {_blockStateMeta}.getBlockState() as {CreatureSpawner}
  {_creatureSpawner}.setSpawnedType({_enum})
  {_blockStateMeta}.setBlockState({_creatureSpawner})
  set {_spawner} to {_spawner} as {ItemStack}
  {_spawner}.setItemMeta({_blockStateMeta})
  return {_spawner}

Error in:
Code:
[20:36:34] [Server thread/INFO]: [Skript] Reloading spawner.sk...
[20:36:34] [Server thread/ERROR]: Can't understand this expression: '{_spawner}.getItemMeta() as {BlockStateMeta}' (spawner.sk, line 11: set {_blockStateMeta} to {_spawner}.getItemMeta() as {BlockStateMeta}')
[20:36:34] [Server thread/ERROR]: Can't understand this expression: '{_blockStateMeta}.getBlockState() as {CreatureSpawner}' (spawner.sk, line 12: set {_creatureSpawner} to {_blockStateMeta}.getBlockState() as {CreatureSpawner}')
[20:36:34] [Server thread/ERROR]: Can't understand this expression: '{_spawner} as {ItemStack}' (spawner.sk, line 15: set {_spawner} to {_spawner} as {ItemStack}')
[20:36:34] [Server thread/INFO]: [Skript] Encountered 3 errors while reloading spawner.sk!

Skript ver: 2.4.1
Server ver: 1.15.2
sk-mirror: 2.0.0

How can i fix?
[doublepost=1585432868,1585417145][/doublepost]up!
 
Code:
import:
    org.bukkit.inventory.meta.BlockStateMeta
    org.bukkit.entity.EntityType
    org.bukkit.block.CreatureSpawner
    org.bukkit.inventory.ItemStack

function spawner(entity: string) :: item:
  set {_enum} to try {EntityType}.valueOf({_entity}.toUpperCase())
  set {_spawner} to mob spawner
  set {_spawner} to {_spawner}.getRandom()
  set {_blockStateMeta} to {_spawner}.getItemMeta() as {BlockStateMeta}
  set {_creatureSpawner} to {_blockStateMeta}.getBlockState() as {CreatureSpawner}
  {_creatureSpawner}.setSpawnedType({_enum})
  {_blockStateMeta}.setBlockState({_creatureSpawner})
  set {_spawner} to {_spawner} as {ItemStack}
  {_spawner}.setItemMeta({_blockStateMeta})
  return {_spawner}

Error in:
Code:
[20:36:34] [Server thread/INFO]: [Skript] Reloading spawner.sk...
[20:36:34] [Server thread/ERROR]: Can't understand this expression: '{_spawner}.getItemMeta() as {BlockStateMeta}' (spawner.sk, line 11: set {_blockStateMeta} to {_spawner}.getItemMeta() as {BlockStateMeta}')
[20:36:34] [Server thread/ERROR]: Can't understand this expression: '{_blockStateMeta}.getBlockState() as {CreatureSpawner}' (spawner.sk, line 12: set {_creatureSpawner} to {_blockStateMeta}.getBlockState() as {CreatureSpawner}')
[20:36:34] [Server thread/ERROR]: Can't understand this expression: '{_spawner} as {ItemStack}' (spawner.sk, line 15: set {_spawner} to {_spawner} as {ItemStack}')
[20:36:34] [Server thread/INFO]: [Skript] Encountered 3 errors while reloading spawner.sk!

Skript ver: 2.4.1
Server ver: 1.15.2
sk-mirror: 2.0.0

How can i fix?
[doublepost=1585432868,1585417145][/doublepost]up!
The snippet is very outdated, try if this works:

Code:
import:
    org.bukkit.inventory.meta.BlockStateMeta
    org.bukkit.entity.EntityType
    org.bukkit.block.CreatureSpawner
    org.bukkit.inventory.ItemStack

function spawner(entity: string) :: item:
    set {_enum} to try EntityType.valueOf({_entity}.toUpperCase())
    set {_spawner} to mob spawner
    set {_spawner} to {_spawner}.getRandom()
    set {_blockStateMeta} to {_spawner}.getItemMeta()
    set {_creatureSpawner} to {_blockStateMeta}.getBlockState()
    {_creatureSpawner}.setSpawnedType({_enum})
    {_blockStateMeta}.setBlockState({_creatureSpawner})
    set {_spawner} to {_spawner}
    {_spawner}.setItemMeta({_blockStateMeta})
    return {_spawner}
 
The snippet is very outdated, try if this works:

Code:
import:
    org.bukkit.inventory.meta.BlockStateMeta
    org.bukkit.entity.EntityType
    org.bukkit.block.CreatureSpawner
    org.bukkit.inventory.ItemStack

function spawner(entity: string) :: item:
    set {_enum} to try EntityType.valueOf({_entity}.toUpperCase())
    set {_spawner} to mob spawner
    set {_spawner} to {_spawner}.getRandom()
    set {_blockStateMeta} to {_spawner}.getItemMeta()
    set {_creatureSpawner} to {_blockStateMeta}.getBlockState()
    {_creatureSpawner}.setSpawnedType({_enum})
    {_blockStateMeta}.setBlockState({_creatureSpawner})
    set {_spawner} to {_spawner}
    {_spawner}.setItemMeta({_blockStateMeta})
    return {_spawner}
Working! Thank you very much.. (15.line is unneeded)

But can i set item spawner(iron ingot spawner like.)?
 
Working! Thank you very much.. (15.line is unneeded)

But can i set item spawner(iron ingot spawner like.)?
You can only change the type of the spawned entity, so you'd have to use DROPPED_ITEM for the entity type.
Then you would need to create a system that turns of all the dropped items into the item you want, you can use SpawnerSpawnEvent for that.
PS I recommend using metadata on the spawners to set their item type.
 
Status
Not open for further replies.