Posted September 23, 20177 yr I'm trying to fix a problem with my mod where it checks even some mod's entity that shouldn't. How can I check if an entity is an instanceof another mod's entity (or any way to check if that mob is a mod's entity) without having to make it a dependence? So far this is what I have if (Loader.isModLoaded("babymobs")){ //if (entity instanceof EntityZombieChicken) That would require the mod's import //or //if (entity.getId() == "babymobs:zombiechicken") That's pseudocode, not actually possible ... I think } Edited September 23, 20177 yr by Insane96MCP
September 23, 20177 yr Your pseudocode is on the right track. To get the string id of the entity, you can pass it into EntityList.getEntityString(). You should also be using Object#equals() to check string equality, rather than ==. == checks identity, it returns true if the two objects are the same object, i.e they are located at the same memory address. Object#equals() returns true if the two objects can be considered equivalent, the definition of equivalence depends on the object. For a String, two Strings are equal if they have the same characters at the same positions. Edited September 23, 20177 yr by Leviathan143 Remove doubled ==.
September 24, 20177 yr Author Is it better use EntityList#getEntityString() or EntityList#getKey().toString()? if (EntityList.getKey(entity).toString().equals("babymobs:zombiechicken")) //or if (EntityList.getEntityString(entity).equals("zombiechicken")
September 24, 20177 yr Author 1 minute ago, Creeper_Guy2008 said: What app are you using? Please don't go off-topic in other peoples' posts.
September 24, 20177 yr If you want to check if a mod is an entity either go in f3 mode and look at the mob and it should say if its an enitity
September 24, 20177 yr If you are on the latest version, afaik it's better to check with EntityEntry registry. Use @ObjectHolder to get the entry and check if the class is the same with the class from the entry. Edited September 24, 20177 yr by Abastro I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
September 29, 20177 yr Author On 24/9/2017 at 0:11 PM, Abastro said: If you are on the latest version, afaik it's better to check with EntityEntry registry. Use @ObjectHolder to get the entry and check if the class is the same with the class from the entry. And if I don't have access to source code? So I don't know the Entity class?
September 29, 20177 yr 2 hours ago, Insane96MCP said: And if I don't have access to source code? So I don't know the Entity class? Well. @ObjectHolder requires Entity ID, not class. If you took a glance on EntityEntry, you must've found that it holds the class you need... So check for entity with the class. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
September 29, 20177 yr On 9/24/2017 at 6:50 AM, Creeper_Guy2008 said: What app are you using? On 9/24/2017 at 6:53 AM, Creeper_Guy2008 said: Ya kinda right On 9/24/2017 at 6:54 AM, Creeper_Guy2008 said: If you want to check if a mod is an entity either go in f3 mode and look at the mob and it should say if its an enitity This is the Modder Support forum, please don't spam and don't suggest stuff you know nothing about.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.