Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

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


Recommended Posts

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.

Link to post
Share on other sites
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
Link to post
Share on other sites

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 by MSpace-Dev
Link to post
Share on other sites

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
Link to post
Share on other sites

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

 

Link to post
Share on other sites
  • MSpace-Dev changed the title to [1.14.4] Dynamic block/entity/item etc based on other mods
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
Link to post
Share on other sites

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 by MSpace-Dev
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.   Restore formatting

  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.



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Just downloaded MDK for 1.17.1, set up my project in IntelliJ IDEA Community 2021.1.3, but there's an error "Exception in thread "main" java.lang.module.ResolutionException: Module jline.terminal reads more than one module named cpw.mods.securejarhandler". Java version is 16.0.2. If I'll try to change it, there'll be new module instead of "jline.terminal". Here's the full log: Exception in thread "main" java.lang.module.ResolutionException: Module jline.terminal reads more than one module named cpw.mods.securejarhandler at java.base/java.lang.module.Resolver.resolveFail(Resolver.java:908) at java.base/java.lang.module.Resolver.checkExportSuppliers(Resolver.java:729) at java.base/java.lang.module.Resolver.finish(Resolver.java:379) at java.base/java.lang.module.Configuration.<init>(Configuration.java:140) at java.base/java.lang.module.Configuration.resolveAndBind(Configuration.java:494) at java.base/java.lang.module.Configuration.resolveAndBind(Configuration.java:298) at cpw.mods.bootstraplauncher@0.1.15/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:77) Process finished with exit code 1 Any ideas to fix it?
    • I'm trying to create a command that Changes the nbt data of the currently held item. Ive gotten to the point where everything works except for this line. EntityPlayer player= sender.getDisplayName(); @Override public void processCommand(ICommandSender sender, String[] args) { String output = String.join(" ", args); if(args.length == 0) { throw new CommandException("no name defined"); } else { EntityPlayer player= sender.getDisplayName(); ItemStack stack = player.getHeldItem(); addInformation(stack, player, output); } } public void addInformation(ItemStack istack, EntityPlayer player, String itemname) { NBTTagCompound tag = istack.stackTagCompound; if (tag == null) { tag = new NBTTagCompound(); tag.setTag("display", new NBTTagCompound()); istack.stackTagCompound = tag; } tag.getTag("display"); tag.setTag("display", new NBTTagCompound()); NBTTagCompound tagname = tag.getCompoundTag("display"); NBTTagList name = new NBTTagList(); name.appendTag(new NBTTagString("§b"+itemname)); tagname.setTag("Name", name); }  
    • How?? I don't know the method that can change time.
    • use the SleepFinishedTimeEvent and set the time in the Event to the time you want
    • I want change how is the time manipulated when player is sleeping
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.