#break mob spawner with mob inside

1 messages · Page 1 of 1 (latest)

teal pecan
#

Hi,
i would like to make a pickaxe that can break mobspawners with their mob inside. The name of the spawner would then be "Mobspawner (%mob%)".
I already got that you get the mobspawner but just normal without mob inside.. I also searched on the internet but nothing really helped.

knotty cloak
teal pecan
#

And how can I implement this to

    drop mob spawner at event-block``` this?
sharp ravine
#

try to use that expression to get the entitytype, then drop 1 of {_entityType} spawner ...

teal pecan
#

Drops an error..

    set {_type} to event-block's entity type
    drop 1 of {_type} spawner at event-block
knotty cloak
#

"%{_type}% spawner" parsed as item type at event-block

sharp ravine
#

Maybe just drop a spawner with a string tag for the entity, then set the entity type to that on place

near cipher
#

on top of that, instead of naming the item (because people can rename things in anvils), you should set a line of lore in the item to be the entity. I use this method for myself: Type: cave_spider
The spawner type will be on its own line, and the underscores are mandatory so the script doesn't get confused when it tries to get the lore (and for readability)
Then you can check the lore and see if it starts with "Type" and get the mob from there, then set the spawner type using the expression shown earlier on place

teal pecan
#

I tried.. I don't get it...

#
    add 1 to {nmb}
    set {spawner.type.%{nmb}%::%uuid of player%} to event-block's entity type
    set name of event-block to "%event-block's entity type% - Spawner" with lore "Type: %event-block's entity type%"

on place:
    if event-block is a spawner:
        lore of event-block contains "Type":
            set entity type of event-block to {spawner.type.%{nmb}%::%uuid of player%}
            remove 1 from {nmb}}```
The {nmb} part is so that you can break several spawners and the mobs are saved and then the right mob is there when you place them. Definitely works better. But in general it doesn't even work...
#

Maybe someone can give me an example. I really can't figure it out...

near cipher
#

The {nmb} variable is unnecessary, and can break if multiple people break the spawners at the same time. I believe another reason it's not working is because you are checking the lore of the block (blocks placed do not have lore), whereas you should be checking the lore of the player's tool

teal pecan
#

Alr. ```on break of mob spawner:
set {_item} to event-block
set {spawner.type::%uuid of player%} to event-block's entity type
set lore of {_item} to "Type: %event-block's entity type%"
set event-block to air
drop 1 of {_item} at event-block

on place:
if player's tool is a spawner:
lore of player's tool contains "Type":
set entity type of event-block to {spawner.type::%uuid of player%}```

I don't have any errors yet. The type is saved, the lore is set but as soon as I place the spawner it is a normal one

near cipher
#

you may then need to waitatick before you set the entity type of the spawner

teal pecan
#

Does not change anything

teal pecan
#

😭

#

The lore condition doesn't work at all
if lore of player's tool contains "&6Mob:":

lost ruin
#

that works

#

whatever lore line its checking has to say that exactly though

#

you have to loop the tool's lore, then check if each loop-value contains a string if you wanted to check a partial match

teal pecan
#

Where do I have to loop that

lost ruin
#

wherever you wanted to put a loop in

teal pecan
#

Damn. It works

#

Thank you ❤️

#
    if held item is a spawner:
        loop the tool's lore:
            loop-value contains "&6Mob:":
                wait 1 tick
                set event-block's entity type to {spawner.type::%uuid of player%}``` 
Like that it works. Is it as you thought?
lost ruin
#

sure 👍

teal pecan
#

Now another thing is, I can't save more than one mob because the last spawner I broke will be saved. How can I make that they save per spawner

sharp ravine
#

Its saved in the lore

#

You dont need a variable too

teal pecan
#

But how do I set the spawner type then

sharp ravine
#

you get it from the lore, not the variable

teal pecan
#

So I have to check the lore if it contains "pig" I have to set the type to pig. Doesn't it work automatically in any way?

#
                    wait 1 tick
                    set event-block's entity type to pig
                if loop-value contains "creeper":
                    wait 1 tick
                    set event-block's entity type to creeper```
This, for example, works. But then I would have to list every mob...
sharp ravine
#

no, just set it to the lore parsed as entity

teal pecan
#
  set event-block's entity type to {_lore}```
There is no error but the mob is not set.
sharp ravine
#

because that isnt just the entity

#

you have mob: in there too

teal pecan
#

So I have to remove that part

#

replace all "&6Mob:" in {_lore} with "" does not work.

near cipher
#

set a temp var to the uncolored loop-value, then replace your text

teal pecan
#
    if held item is a spawner:
        loop the tool's lore:
            loop-value contains "&6Mob:":
                set {_lore} to 1st line of tool's lore
                replace every "&6Mob: " in {_lore} with ""
                broadcast "%{_lore}%"
                wait 1 tick
                set event-block's entity type to {_lore} parsed as entity```
It's broadcasting the type but it does not set the type..
sharp ravine
#

its broadcasting the string

#

but not parsing as an entity, because its not an entity

#

its an entitytype

teal pecan
#

I almost have it... Why does it have to be so complicated. 😭

sharp ravine
#

an entity is a physical (well, in the world of Minecraft) entity. it has to be alive, and exist somewhere

teal pecan
#

And how can I do it then?.

sharp ravine
teal pecan
#

THATS IT