#EntityTypes nms

1 messages · Page 1 of 1 (latest)

cerulean badge
#

ah

#

fixed it

#

EntityType.byString(entityType.ZOMBIE.getKey().toString()) works

vale helm
#

hello

soft berry
#

hey

vale helm
#

are you trying to get the nms EntityTypes that corresponds to a pig?

#

and spawn a pig from it?

soft berry
#

yes

vale helm
#

ah ok I don't think you can ever infer from the Bukkit class directly

soft berry
#

i have tried with setTarget or vectors but setTarget didn't work and vectors were very ugly

vale helm
#

The way I have done it in the past is using this method EntityType.byString(String)

#

it may be called differently in your version of nms

soft berry
#

byString doesn't exist

vale helm
#

is your nms obfuscated

#

that means methods look like a() etc.

soft berry
#

yes

vale helm
#

there might be a method that takes in a String and returns an Optional<EntityType<?>>

#

that will be the method I am referring to

soft berry
#

hmm

vale helm
#

static method

soft berry
#

after EntittyType there only appears method about entities

#

or this few

#

maybe fromName?

vale helm
#

This aside, I think you can simply spawn a pig by World#spawnEntity(EntityType)

#

wait

mighty bane
#

if u want to spawn a pig using nms can't u just use

new EntityPig(EntityTypes.PIG, world).spawnIn(world);
soft berry
#

but wait

#

i have a custom pig with pathfindergoals

mighty bane
#

still u can do that

soft berry
#

i don't want to spawn a normal pig

#

new EntityPig(pig.class...) ?

mighty bane
#

u don't have to

#

just make a custom class

#

that extends EntityPig (that's how I normally make custom entities in NMS)

soft berry
#

i have it already

mighty bane
#

so

#

just use the spawnIn method

soft berry
#

the problem is spawning it

#

there

mighty bane
#

that's not what I m talking about tho

soft berry
#

wdym

vale helm
# soft berry

does getHandle() give you EntityTypes or EntityPig instance

icy lava
#

To check, you want to spawn a pig via NMS basically?

soft berry
#

well, yes

icy lava
#

I might have a snippet that can help you then

soft berry
#

but can't spawn it by spigot code because have custom pathfinder

#

basically

icy lava
#

I've done something similar with custom magma cubes

soft berry
#

let me check

#

thanks

icy lava
#

I use reflection though, rather than the more direct way you do, so you'll have to do a bit of converting 😄

#

For how I figured it out, if you need to too, is by decompiling the spigot jar using jd-gui, and looking at it's source

mighty bane
#

but that's assuming that u r controlling the mob using nms

soft berry
#

i have it

#

i'm actually learning about that

mighty bane
soft berry
mighty bane
#

um, ye idk if I can help u with something I haven't watched (I thought I could so I came but that video is different then others)