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

    • JayNeedsHelp
      How can I fix this encoding issue?

      By JayNeedsHelp · Posted 2 hours ago

      Hey so I'm creating a forge mod and I'm trying to use the "§" character but I'm getting an illegal character error in the compiler. I've tried using the -encoding option in the compiler, I've also tried converting the file to UTF-8 without BOM, but it wasn't UTF-8 BOM in the first place. I was making a jar mod with mcp in eclipse and everything was working just fine with these characters, which I'm now moving to a forge mod. I'm using IntelliJ Community IDEA currently.   Here's a link to part of the error list: https://jay-hosts-a.dark-web.store/6AXsbJqG. Obviously the other errors were due to the illegal character error but I thought I might as well show it. I'm making a forge mod for 1.12.2, forgegradle is version 2.3-SNAPSHOT and I'm using mixingradle-0.6-SNAPSHOT.   I'm not sure how to fix this and any help would be greatly appreciated.
    • mchase
      Forge crashing

      By mchase · Posted 2 hours ago

      I downloaded and installed forge for 1.16.4 and it shows up in my installations and will start to open but then crashes and gives me "exit code 255". I am on MacOS if that makes a difference. it says The game crashed whilst initializing game Error: java.lang.IllegalStateException: GLFW error before init: [0x10008]Cocoa: Failed to find service port for display Exit Code: 255 does forge just not work on Mac? am I missing something? please help
    • MiToKonndria
      cant download pixelmon

      By MiToKonndria · Posted 2 hours ago

      when i click install on the Pixelmon modpack it gets to 42% and mod 3 out of 7 and then gives me the error message: Timeout attempting to download: "https://edge.forgecdn.net/files/3072/298/pixelmon-1.12.2-8.1.2-universal.jar"
    • lupicus
      can someone help with server crashing

      By lupicus · Posted 2 hours ago

      Looks like Wonderful Enchantments has problems, try and remove it.
    • Draco18s
      can someone help with server crashing

      By Draco18s · Posted 2 hours ago

      Surprise, accessing the client thread from the server thread isn't possible. Bitch at the author of wonderfulenchantments.
  • Topics

    • JayNeedsHelp
      0
      How can I fix this encoding issue?

      By JayNeedsHelp
      Started 2 hours ago

    • mchase
      0
      Forge crashing

      By mchase
      Started 2 hours ago

    • MiToKonndria
      0
      cant download pixelmon

      By MiToKonndria
      Started 2 hours ago

    • IRONDALEK
      3
      can someone help with server crashing

      By IRONDALEK
      Started 7 hours ago

    • Twu
      0
      Need help with Potion Brewing recipes

      By Twu
      Started 2 hours ago

  • Who's Online (See full list)

    • MiToKonndria
    • D_Captain
    • Foofantastic
    • HappyAndJust
    • fan87
    • BakaJzon
  • 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