Jump to content
  • Home
  • Files
  • Docs
  • Merch
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
  • [1.14.4] Dynamic block/entity/item etc based on other mods
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 1
MSpace-Dev

[1.14.4] Dynamic block/entity/item etc based on other mods

By MSpace-Dev, November 19 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

MSpace-Dev    12

MSpace-Dev

MSpace-Dev    12

  • Creeper Killer
  • MSpace-Dev
  • Members
  • 12
  • 180 posts
Posted November 19

Is it possible to get all loaded entities in the registry (from all other mods) at runtime, to then be able to spawn in said entity within my mod? I feel it might be possible now, with how structured the registry events are in 1.14.

I am also trying to generate new entities at runtime based on this by using a builder pattern of sorts.

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6684

diesieben07

diesieben07    6684

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6684
  • 45696 posts
Posted November 19
3 hours ago, MSpace-Dev said:

Is it possible to get all loaded entities in the registry (from all other mods) at runtime

I assume you mean entity types, not entities. You can find all registries in the ForgeRegistries class, in this case you want ForgeRegistries.ENTITIES.

 

3 hours ago, MSpace-Dev said:

I am also trying to generate new entities at runtime based on this by using a builder pattern of sorts.

The EntityType has various methods to create new entities of that type.

  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

MSpace-Dev    12

MSpace-Dev

MSpace-Dev    12

  • Creeper Killer
  • MSpace-Dev
  • Members
  • 12
  • 180 posts
Posted November 19 (edited)

I've been doing some research. What are your thoughts on this method?

	@SubscribeEvent
	public static void onRegisterEntities(final RegistryEvent.Register<EntityType<?>> event)
	{
		DeferredWorkQueue.runLater(() -> {
			entityBuilder(event);
		});
	}

	private static void entityBuilder(final RegistryEvent.Register<EntityType<?>> event)
	{
		ArrayList<EntityType<?>> all_entities;
		all_entities = (ArrayList<EntityType<?>>) event.getRegistry().getValues();

		Main.LOGGER.debug("ALL LOADED ENTITIES:");
		all_entities.forEach(p -> Main.LOGGER.debug(p));
	}

 

And will I be able to register new entities under new IDs using the methods within EntityType and ForgeRegistries.ENTITIES? (If I don't go with this method ^)

Edited November 19 by MSpace-Dev
  • Quote

Share this post


Link to post
Share on other sites

MSpace-Dev    12

MSpace-Dev

MSpace-Dev    12

  • Creeper Killer
  • MSpace-Dev
  • Members
  • 12
  • 180 posts
Posted November 19

Well, that actually does not run. DeferredWorkQueue#runLater does not get called. 

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6684

diesieben07

diesieben07    6684

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6684
  • 45696 posts
Posted November 19

Don't obtain the entities in that event. Just access the registry directly whenever you need it.

 

41 minutes ago, MSpace-Dev said:

And will I be able to register new entities under new IDs using the methods within EntityType and ForgeRegistries.ENTITIES? (If I don't go with this method ^)

No. New entities must be registered at startup, in the appropriate registry event. You should also not register a dynamic set of entries. Your mod should always register the same things, regardless of configuration or other circumstances.

  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

MSpace-Dev    12

MSpace-Dev

MSpace-Dev    12

  • Creeper Killer
  • MSpace-Dev
  • Members
  • 12
  • 180 posts
Posted November 19

So, creating new entity types based on other mods is impossible?

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6684

diesieben07

diesieben07    6684

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6684
  • 45696 posts
Posted November 19
Just now, MSpace-Dev said:

So, creating new entity types based on other mods is impossible?

It's not impossible, but it is discouraged. Why do you want to do that? What result are you trying to achieve?

  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

MSpace-Dev    12

MSpace-Dev

MSpace-Dev    12

  • Creeper Killer
  • MSpace-Dev
  • Members
  • 12
  • 180 posts
Posted November 19

I want to expand my mod's features lots in 1.14.4. I want users to be able to specify mobIDs from other mods in JSON to initialise a new item, block and entity for the specified id. To do this, I need to be able to dynamically create these objects.

 

It would be perfect for my mod. You will be able to see that at a quick glance I think:

https://www.curseforge.com/minecraft/mc-mods/monster-totems

 

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6684

diesieben07

diesieben07    6684

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6684
  • 45696 posts
Posted November 19
2 minutes ago, MSpace-Dev said:

To do this, I need to be able to dynamically create these objects.

Correct, but they do not need to be separate items/blocks/entities.

In this case you would make one item/block/entity which can pose as any other.

  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

MSpace-Dev    12

MSpace-Dev

MSpace-Dev    12

  • Creeper Killer
  • MSpace-Dev
  • Members
  • 12
  • 180 posts
Posted November 19

How would I achieve something like that roughly? Any suggestions / resources I can look into?

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6684

diesieben07

diesieben07    6684

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6684
  • 45696 posts
Posted November 19
1 minute ago, MSpace-Dev said:

How would I achieve something like that roughly? Any suggestions / resources I can look into?

Take entities for example. You would write one entity class. This entity class takes whatever data has been configured in the JSON as a constructor parameter. For example an EntityType combined with some spawn information (e.g. spawn with a sword, or whatever features you want). Then this entity needs to act according to this configuration.

  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

MSpace-Dev    12

MSpace-Dev

MSpace-Dev    12

  • Creeper Killer
  • MSpace-Dev
  • Members
  • 12
  • 180 posts
Posted November 19 (edited)

Ah, thanks. I will look into it further tomorrow morning. I have to head off to sleep, but hope I can get something working. Forge 1.14 is a rather large step in the right direction from what I've seen so far!

Edited November 19 by MSpace-Dev
  • 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

    • EmerProd
      Forge 1.12.2 Crash

      By EmerProd · Posted 16 minutes ago

      It worked by removing the 1.7.10 and 1.8.9 Optifine from mods folder, thank you.
    • J3sq
      Minecraft v1.15 - Supported by Forge?

      By J3sq · Posted 16 minutes ago

      I have just re-installed Minecraft Java Edition onto a new Windows 10 PC, after a while of not playing. I haven't had many issues with modding (that I couldn't solve through reading) in the past, however this time I can't seem to get Forge to recognise any mods. I'm fairly sure my issue is that I'm running version 1.15 of Minecraft and version 1.14.4 of Forge - I have searched and searched for Forge 1.15 and have found a couple of dodgy links (which I did not click), however as Forge version 1.15 is not on the official site I was wondering if anyone can advise me on what to do? Is there a current fix for this or do I just wait for a compatible version?   debug.log: https://pastebin.com/6HzEwf0K    
    • bandofbros20
      1.12.2 Forge isnt working, are these the logs you need?

      By bandofbros20 · Posted 35 minutes ago

      [1211/164737.130:WARNING:angle_platform_impl.cc(41)] rx::HLSLCompiler::compileToBinary(224):  C:\fakepath(37,8-56): warning X3571: pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them C:\fakepath(43,8-26): warning X3571: pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them
    • Draco18s
      Distinguish singleplayer vs. multiplayer

      By Draco18s · Posted 59 minutes ago

      Items are not proxies. Proxies are proxies, Items are Items. The Item is supposed to call a method in the proxy, it is not the proxy itself.
    • vMystic
      [1.12.2] plugin with id 'net.minecraftforge.gradle.forge' not found

      By vMystic · Posted 1 hour ago

      Ive tried googling for a long time and i cant find anything on this, Whenever I try to run gradlew setupDecompWorkspace I get the error plugin with id 'net.minecraftforge.gradle.forge' not found ive talked with someone and they said the people here can help me with this issue. Any suggestions?
  • Topics

    • EmerProd
      4
      Forge 1.12.2 Crash

      By EmerProd
      Started Sunday at 06:23 PM

    • J3sq
      0
      Minecraft v1.15 - Supported by Forge?

      By J3sq
      Started 16 minutes ago

    • bandofbros20
      0
      1.12.2 Forge isnt working, are these the logs you need?

      By bandofbros20
      Started 35 minutes ago

    • solitone
      15
      Distinguish singleplayer vs. multiplayer

      By solitone
      Started December 5

    • vMystic
      0
      [1.12.2] plugin with id 'net.minecraftforge.gradle.forge' not found

      By vMystic
      Started 1 hour ago

  • Who's Online (See full list)

    • J3sq
    • Ellis,Hunter
    • plugsmustard
    • Ommina
    • coolsim
    • ComputerCraft32
    • Darren Hayden
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.14.4] Dynamic block/entity/item etc based on other mods
  • Theme
  • Contact Us
  • Discord

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