Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Detect another mod's entity
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
Insane96MCP

Detect another mod's entity

By Insane96MCP, September 23, 2017 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Insane96MCP    2

Insane96MCP

Insane96MCP    2

  • Creeper Killer
  • Insane96MCP
  • Members
  • 2
  • 211 posts
Posted September 23, 2017 (edited)

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, 2017 by Insane96MCP
  • Quote

Share this post


Link to post
Share on other sites

Leviathan143    40

Leviathan143

Leviathan143    40

  • Creeper Killer
  • Leviathan143
  • Forge Modder
  • 40
  • 211 posts
Posted September 23, 2017 (edited)

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, 2017 by Leviathan143
Remove doubled ==.
  • Quote

Share this post


Link to post
Share on other sites

Insane96MCP    2

Insane96MCP

Insane96MCP    2

  • Creeper Killer
  • Insane96MCP
  • Members
  • 2
  • 211 posts
Posted September 24, 2017

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")

 

  • Quote

Share this post


Link to post
Share on other sites

Creeper_Guy2008    0

Creeper_Guy2008

Creeper_Guy2008    0

  • Tree Puncher
  • Creeper_Guy2008
  • Members
  • 0
  • 4 posts
Posted September 24, 2017

What app are you using?

 

  • Quote

Share this post


Link to post
Share on other sites

Insane96MCP    2

Insane96MCP

Insane96MCP    2

  • Creeper Killer
  • Insane96MCP
  • Members
  • 2
  • 211 posts
Posted September 24, 2017
1 minute ago, Creeper_Guy2008 said:

What app are you using?

 

Please don't go off-topic in other peoples' posts.

  • Quote

Share this post


Link to post
Share on other sites

Creeper_Guy2008    0

Creeper_Guy2008

Creeper_Guy2008    0

  • Tree Puncher
  • Creeper_Guy2008
  • Members
  • 0
  • 4 posts
Posted September 24, 2017

Ya kinda right

 

  • Quote

Share this post


Link to post
Share on other sites

Creeper_Guy2008    0

Creeper_Guy2008

Creeper_Guy2008    0

  • Tree Puncher
  • Creeper_Guy2008
  • Members
  • 0
  • 4 posts
Posted September 24, 2017

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

 

  • Quote

Share this post


Link to post
Share on other sites

Abastro    123

Abastro

Abastro    123

  • World Shaper
  • Abastro
  • Forge Modder
  • 123
  • 1075 posts
Posted September 24, 2017 (edited)

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, 2017 by Abastro
  • Quote

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Share this post


Link to post
Share on other sites

Insane96MCP    2

Insane96MCP

Insane96MCP    2

  • Creeper Killer
  • Insane96MCP
  • Members
  • 2
  • 211 posts
Posted September 29, 2017
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?

  • Quote

Share this post


Link to post
Share on other sites

Abastro    123

Abastro

Abastro    123

  • World Shaper
  • Abastro
  • Forge Modder
  • 123
  • 1075 posts
Posted September 29, 2017
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.

  • Quote

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Share this post


Link to post
Share on other sites

MrBendelScrolls    16

MrBendelScrolls

MrBendelScrolls    16

  • Creeper Killer
  • MrBendelScrolls
  • Members
  • 16
  • 115 posts
Posted September 29, 2017
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.

  • Quote

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • TheMajorN
      Trying to make a crop have an "X" shape model

      By TheMajorN · Posted 2 minutes ago

      Heya,  So I created a crop and have everything in order with it, however I'm trying to change it from the square shape that it uses, as all crops use, to the X shape that flowers use.  How would I go about doing that? Any point in the right direction would be appreciated
    • Sepiceay
      RLCraft 2.8.2 Keeps crashing with the error code as follows

      By Sepiceay · Posted 24 minutes ago

      Unable to launch java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 6 at net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper.injectIntoClassLoader(CoreModManager.java:169) at net.minecraft.launchwrapper.Launch.launch(Launch.java:115) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) Caused by: java.lang.ArrayIndexOutOfBoundsException: 6 at org.objectweb.asm.ClassReader.readShort(Unknown Source) at org.objectweb.asm.ClassReader.<init>(Unknown Source) at org.objectweb.asm.ClassReader.<init>(Unknown Source) at net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper.getFieldType(FMLDeobfuscatingRemapper.java:224) at net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper.parseField(FMLDeobfuscatingRemapper.java:192) at net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper.setup(FMLDeobfuscatingRemapper.java:161) at net.minecraftforge.fml.common.asm.FMLSanityChecker.injectData(FMLSanityChecker.java:187) at net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper.injectIntoClassLoader(CoreModManager.java:164) ... 2 more I have restarted my computer and reinstalled the profile multiple times but I keep getting this error on startup. I can provide more lines if needed because all I need to do to replicate the logs is to try and open RLCraft. www
    • samjviana
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By samjviana · Posted 55 minutes ago

      I making some custom emchantment, and would like them to show up on an Custom ItemGroup, but i don't know where to start, i tried looking into some classes and did some google about it, but can't find anything usefull.
    • ESCCarp
      Forge says this file does not have an app associated with it.

      By ESCCarp · Posted 1 hour ago

      i do  
    • LexManos
      forge a jar file not exe

      By LexManos · Posted 2 hours ago

      Some zip managers like to take control of the .jar file extension away from Java. Make sure you have Java installed and try running Jarfix once, then try the installer again.   Also, 1.12 is out of support, update.
  • Topics

    • TheMajorN
      0
      Trying to make a crop have an "X" shape model

      By TheMajorN
      Started 2 minutes ago

    • Sepiceay
      0
      RLCraft 2.8.2 Keeps crashing with the error code as follows

      By Sepiceay
      Started 24 minutes ago

    • samjviana
      0
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By samjviana
      Started 55 minutes ago

    • ESCCarp
      2
      Forge says this file does not have an app associated with it.

      By ESCCarp
      Started 2 hours ago

    • Modder31
      1
      forge a jar file not exe

      By Modder31
      Started 2 hours ago

  • Who's Online (See full list)

    • TheMajorN
    • Loganator711
    • IDontCaboose
    • DWyvern
    • Chumbanotz
    • foxythesweat
    • redlynx
    • Sepiceay
    • -MCS_Gaming-
    • hammy3502
    • Daeruin
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Detect another mod's entity
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community