#EntityTypegetType() uses NMS interally right? Because i need to stop player killing mobs and i need

1 messages · Page 1 of 1 (latest)

hollow meteor
#

Hi

#

I want to know if EntityType#getType() interally uses NMS

elfin tapir
#

oh that

#

yes

hollow meteor
#

Because i need to stop players killing mobs on 1.17 and 1.19 with the same plugin

elfin tapir
#

under the hood everything is essentially NMS

#

Spigot just exposes it in a user friendly way

hollow meteor
#

Yeah

elfin tapir
#

aka spigot-api

hollow meteor
#

Burch doesnt it apply?

#

Because im abit annoyed with that part

#

Maybe i do a abstract class Entities (adding the common ones there) and then creating a 1.17 and 1.19 impl

#

What do you think?

#

And also thanks for helping man

brave pecan
#

there's no point

#

one server calls 1 version

#

the other server calls the other version

#

EntityType is a spigot wrapper, it doesn't return the nms type

#

so you're fine

hollow meteor
#

Ilussion

#

But what about on the event?

brave pecan
#

spigot isn't that fragile

#

all events return spigot types

#

only reason you should worry about that is if you're modifying pathfinders or nms mob behavior

hollow meteor
#

Okay, so i just do a Set<String> with all mob entities on last version

brave pecan
#

You can do those MinecraftVersion utilities and then like

hollow meteor
#

because ilusion

brave pecan
#

if(MinecraftVersion.isNewerThan(1.18)
register118mobs

if(...)

hollow meteor
#

I just need to stop damage to mobs on 1.16 and 1.19

brave pecan
#

yeah spigot is forwards compatible

hollow meteor
#

Okay but what about mobs so?

brave pecan
#

hmm

#

maybe a registerMobType that just adds an enum value to an enumset

#

with a trycatch

hollow meteor
#

Hmn im confuse

#

Sorry

#

So a EnumSet<EntityType> ?

sharp panther
#

bro

#

just check the entity type against the set

#

and you are fine

elfin tapir
#

EntityType.valueOf(String)

#

catch illegal argument exception

#

return null if so

#

returns a EntityType of the current running spigot server

#

sadly i wish EntityType had getEntity() like how Material has getMaterial

sharp panther
#
Set<String> entities = new HashSet<>();

if (entities.contains(event.getEntity().getType().name()))
   event.setCancelled(true);```
elfin tapir
#

^

hollow meteor
#

okay

#

Allright

#

Thanks!!

#

BUMP

sinful pasture
#

just check stash

hollow meteor
#

I cannot do that

sinful pasture
#

you can

hollow meteor
#

Because on 1.16 and 1.19 mobs are diff

sinful pasture
#

ah uh

hollow meteor
#

That why haha

#

The one I think would better would be checking entity name and comparing over a Set

twin sigil
#

Yes it does

hollow meteor
#

What y2k?