Jump to content

1.12.2 - Natural spawning entities


projectmayhem1983

Recommended Posts

When registering(or rather creating EntityEntry for your entity but if you are doing things correctly you are doing both on the same line of code anyway) your entities use the EntityEntryBuilder#spawn to add your entity entry to biomes listed in order for your entity to spawn in them.

 

...Although I suspect that whatever tutorial you are watching is telling you to use EntityRegistry. Which is an outdated way of registering entities and you should not be using it. Am I correct?

 

As a side note I would also recommend not using tutorials on youtube at all. They are created by people who also just started modding, picked up all the wrong ideas and practices but are eager to share their discoveries with the world. I have yet to see a modern, good tutorial on youtube.

Link to comment
Share on other sites

I have this in my RegistryHandler.java file

 

public static void preInitRegistries()
	{
		EntityInit.registerEntities();
		RenderHandler.registerEntityRenders();
	}

Assuming that is what you are referring to. I'm 100% new to all this, trying to use it as a way to learn java, while also reading books. My actual EntityInfernoSkeleton.java file is pretty much a copy/pasted version of EntitySkeleton, but removed the burning in sunlight.
Is there a good tutorial series , not on youtube , that I should look at?

Link to comment
Share on other sites

Ahhh, think I understand the part you are talking about now, its in my EntityInit file.

package com.projectmayhem1983.skeletonmod.init;

import com.projectmayhem1983.skeletonmod.Main;
import com.projectmayhem1983.skeletonmod.util.Reference;

import com.projectmayhem1983.skeletonmod.entity.EntityInfernoSkeleton;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.EntityRegistry;

public class EntityInit {

	public static void registerEntities()
	{
		registerEntity("infernoskeleton", EntityInfernoSkeleton.class, Reference.ENTITY_INFERNO, 50, 16777215, 8519680);
	}
	public static void registerEntity(String name, Class<? extends Entity> entity, int id, int range, int color1, int color2)
	{
		EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID + ":" + name), entity, name, id, Main.instance, range, 1, true, color1, color2);
	}
}

 

This is the part you were asking about, right?

Link to comment
Share on other sites

23 minutes ago, projectmayhem1983 said:

Is there a good tutorial series , not on youtube , that I should look at?

Well you could read forge's official docs. They are not exactly a tutorial though. 

Apart from that not really, I haven't seen any good tutorial. Even praised modders like McJty make numerous mistakes in their tutorials and enforce cargo-cult programming. I guess the best way to learn is to consult forge docs, look at some open-source mods that are trustworthy, look at vanilla and ask on these forums. I could recommend some repositories I've looked at and they look fine to me - here, here, here, here is mine. Anyone is also welcome to cotribute their repositories if they want to and they feel confident enough in them.

 

23 minutes ago, projectmayhem1983 said:

public static void preInitRegistries() { EntityInit.registerEntities(); RenderHandler.registerEntityRenders(); }

Yeah, this just screams instantinating at wrong time & place. Also it likely calls client-side only code in a common environment which will crash the server.

 

14 minutes ago, projectmayhem1983 said:

Ahhh, think I understand the part you are talking about now, its in my EntityInit file.

Yeah, this is the outdated way to register your entities. Entities are now registered with EntityEntry which is a IForgeRegistryEntry itself so it has a propper registry event fired for it.

Basically subscribe to RegistryEvent.Register<EntityEntry> and use EntityEntryBuilder to register your entities in that event directly. Like this:

@SubscribeEvent
public static void onEntityRegistry(RegistryEvent.Register<EntityEntry> event)
{
    event.getRegistry().register(EntityEntryBuilder.create().entity(YourEntity.class).id(new ResourceLocation(MODID, NAME), NETWORK_ID).name(NAME).tracker(RANGE, FREQUENCY, SEND_VELOCITY).spawn(EnumCreatureType.WANTED_TYPE, WEIGHT, MIN, MAX, BIOMES).egg(COLOR_FORE, COLOR_BACK).build());
}

 

  • Like 1
Link to comment
Share on other sites

Looking at the second example you linked, and I think it helped a lot. The only problem I have now, is in my RegistryHandler file, this part comes up as an error....

public static void preInitRegistries()
	{
		EntityInit.registerEntities();    <-----Error here. The method resisterEntities is undefined for the type EntityInit
		RenderHandler.registerEntityRenders();
	}

 

Probably something simple that I'm not understanding as a novice. But in my EntityInit file, I have this...

 

@SubscribeEvent
		public static void registerEntities(final RegistryEvent.Register<EntityEntry> event) {
			final EntityEntry[] entries = {
					createBuilder("inferno_skeleton")
							.entity(EntityInfernoSkeleton.class)
							.tracker(80, 3, true)
							.build()
			}

 

Do I just need to get rid of the Entity.registerEntities() in my RegistryHandler? Or do I still need it there?

Link to comment
Share on other sites

Also, thank you for the help and references so far. Having fully functional mods to look at helps a lot. Seems to be a lot of different ways you can approach doing things, which makes it a little confusing for a new person.

 

 

EDIT - Tested it out after deleting the RegistryHandler entry, and the mob spawned at night, so that works, but the spawn egg vanished, so gotta work on that now. Thank again for your help!

Edited by projectmayhem1983
Link to comment
Share on other sites

10 minutes ago, projectmayhem1983 said:

Do I just need to get rid of the Entity.registerEntities() in my RegistryHandler? Or do I still need it there?

Well obviously if you've deleted the method you can't keep a reference to it. This is basic java.

Also make sure your event handler is actually registered. And it would probably help if you were to actually register the EntityEntry objects you are creating instead of putting them into an array and doing nothing with said array.

Link to comment
Share on other sites

The rest of the file does something with the array. I have just one last question though, why isn't the new code I used above considered a method? Is it because of the stuff inside the parentheses? 

public static void registerEntities(final RegistryEvent.Register<EntityEntry> event)

 

The old method I was using had nothing.

 

public static void registerEntities()

 

Sorry if this is a really noob question, just wanting to understand what made it not a valid method so I don't have to ask these questions in the future.

Link to comment
Share on other sites

10 minutes ago, projectmayhem1983 said:

why isn't the new code I used above considered a method?

I don't even know what you are trying to say. The code you've provided declares a valid method. There is nothing wrong about it. You might want to learn java before trying to create mods for the game otherwise it will be like assembling a rocket without any instructions. 

Link to comment
Share on other sites

I guess that is what I am confused about then. I was trying to call the method in my RegistryHandler , but it was saying it was undefined. No worries though, like I said, it works now. I've got a few java books I'm reading though, I learn best hands on though, so I been reading during my breaks at work, then working on this mod on my off days to try and get some hands on experience with what I've read. Just sometimes, like this, I just don't comprehend why it was giving me an error.

Link to comment
Share on other sites

  • 1 year later...

 

Quote

@SubscribeEvent
		public static void registerEntities(final RegistryEvent.Register<EntityEntry> event) {
			final EntityEntry[] entries = {
					createBuilder("inferno_skeleton")
							.entity(EntityInfernoSkeleton.class)
							.tracker(80, 3, true)
							.build()
			}

 

Do I just need to get rid of the Entity.registerEntities() in my RegistryHandler? Or do I still need it there?

 

 

Hi could you help me please because When I did the thing that you do I got a error at the creatbuilder line and the error say "Create method 'createBuilder(String)' "

 

here is my EntityInit file:

 

package com.azizsmod.aziz.init;

import com.azizsmod.aziz.entity.EntityCoyoteMob;
import com.azizsmod.aziz.util.handlers.ConfigHandler;

import net.minecraft.entity.Entity;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.EntityEntry;

public class EntityInit  
{ 
	/*
	public static void registerEntities()
	{
		registerEntity("Coyote", EntityCoyoteMob.class, ConfigHandler.ENTITY_COYOTE, 50, 16777215, 8519680);
	}
	*/
	
	@SubscribeEvent
	public static void registerEntities(final RegistryEvent.Register<EntityEntry> event) {
		final EntityEntry[] entries = {
				createBuilder("Coyote") //----------- error is here :(
						.entity(EntityCoyoteMob.class)
						.tracker(50, 3, true)
						.build()
			};
		}

	/*
	private static void registerEntity(String name, Class<? extends Entity> entity, int id, int range, int color1, int color2)
	{
		EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID + ":" + name), entity, name, id, azizsmod.instance, range, 1, true, color1, color2);
	}
    	*/
}

 

Edited by Aziz
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • OLXTOTO: Platform Maxwin dan Gacor Terbesar Sepanjang Masa OLXTOTO telah menetapkan standar baru dalam dunia perjudian dengan menjadi platform terbesar untuk pengalaman gaming yang penuh kemenangan dan kegacoran, sepanjang masa. Dengan fokus yang kuat pada menyediakan permainan yang menghadirkan kesenangan tanpa batas dan peluang kemenangan besar, OLXTOTO telah menjadi pilihan utama bagi para pencinta judi berani di Indonesia. Maxwin: Mengejar Kemenangan Terbesar Maxwin bukan sekadar kata-kata kosong di OLXTOTO. Ini adalah konsep yang ditanamkan dalam setiap aspek permainan yang mereka tawarkan. Dari permainan slot yang menghadirkan jackpot besar hingga berbagai opsi permainan togel dengan hadiah fantastis, para pemain dapat memperoleh peluang nyata untuk mencapai kemenangan terbesar dalam setiap taruhan yang mereka lakukan. OLXTOTO tidak hanya menawarkan kesempatan untuk menang, tetapi juga menjadi wadah bagi para pemain untuk meraih impian mereka dalam perjudian yang berani. Gacor: Keberuntungan yang Tak Tertandingi Keberuntungan seringkali menjadi faktor penting dalam perjudian, dan OLXTOTO memahami betul akan hal ini. Dengan berbagai strategi dan analisis yang disediakan, pemain dapat menemukan peluang gacor yang tidak tertandingi dalam setiap taruhan. Dari hasil togel yang tepat hingga putaran slot yang menguntungkan, OLXTOTO memastikan bahwa setiap taruhan memiliki potensi untuk menjadi momen yang mengubah hidup. Inovasi dan Kualitas Tanpa Batas Tidak puas dengan prestasi masa lalu, OLXTOTO terus berinovasi untuk memberikan pengalaman gaming terbaik kepada para pengguna. Dengan menggabungkan teknologi terbaru dengan desain yang ramah pengguna, platform ini menyajikan antarmuka yang mudah digunakan tanpa mengorbankan kualitas. Setiap pembaruan dan peningkatan dilakukan dengan tujuan tunggal: memberikan pengalaman gaming yang tanpa kompromi kepada setiap pengguna. Komitmen Terhadap Kepuasan Pelanggan Di balik kesuksesan OLXTOTO adalah komitmen mereka terhadap kepuasan pelanggan. Tim dukungan pelanggan yang profesional siap membantu para pemain dalam setiap langkah perjalanan gaming mereka. Dari pertanyaan teknis hingga bantuan dengan transaksi keuangan, OLXTOTO selalu siap memberikan pelayanan terbaik kepada para pengguna mereka. Penutup: Mengukir Sejarah dalam Dunia Perjudian Daring OLXTOTO bukan sekadar platform perjudian berani biasa. Ini adalah ikon dalam dunia perjudian daring Indonesia, sebuah destinasi yang menyatukan kemenangan dan keberuntungan dalam satu tempat yang mengasyikkan. Dengan komitmen mereka terhadap kualitas, inovasi, dan kepuasan pelanggan, OLXTOTO terus mengukir sejarah dalam dunia perjudian berani, menjadi nama yang tak terpisahkan dari pengalaman gaming terbaik. Bersiaplah untuk mengalami sensasi kemenangan terbesar dan keberuntungan tak terduga di OLXTOTO - platform maxwin dan gacor terbesar sepanjang masa.
    • OLXTOTO - Bandar Togel Online Dan Slot Terbesar Di Indonesia OLXTOTO telah lama dikenal sebagai salah satu bandar online terkemuka di Indonesia, terutama dalam pasar togel dan slot. Dengan reputasi yang solid dan pengalaman bertahun-tahun, OLXTOTO menawarkan platform yang aman dan andal bagi para penggemar perjudian daring. DAFTAR OLXTOTO DISINI DAFTAR OLXTOTO DISINI DAFTAR OLXTOTO DISINI Beragam Permainan Togel Sebagai bandar online terbesar di Indonesia, OLXTOTO menawarkan berbagai macam permainan togel. Mulai dari togel Singapura, togel Hongkong, hingga togel Sidney, pemain memiliki banyak pilihan untuk mencoba keberuntungan mereka. Dengan sistem yang transparan dan hasil yang adil, OLXTOTO memastikan bahwa setiap taruhan diproses dengan cepat dan tanpa keadaan. Slot Online Berkualitas Selain togel, OLXTOTO juga menawarkan berbagai permainan slot online yang menarik. Dari slot klasik hingga slot video modern, pemain dapat menemukan berbagai opsi permainan yang sesuai dengan preferensi mereka. Dengan grafis yang memukau dan fitur bonus yang menggiurkan, pengalaman bermain slot di OLXTOTO tidak akan pernah membosankan. Keamanan dan Kepuasan Pelanggan Terjamin Keamanan dan kepuasan pelanggan merupakan prioritas utama di OLXTOTO. Mereka menggunakan teknologi enkripsi terbaru untuk melindungi data pribadi dan keuangan para pemain. Tim dukungan pelanggan yang ramah dan responsif siap membantu pemain dengan setiap pertanyaan atau masalah yang mereka hadapi. Promosi dan Bonus Menarik OLXTOTO sering menawarkan promosi dan bonus menarik kepada para pemainnya. Mulai dari bonus selamat datang hingga bonus deposit, pemain memiliki kesempatan untuk meningkatkan kemenangan mereka dengan memanfaatkan berbagai penawaran yang tersedia. Penutup Dengan reputasi yang solid, beragam permainan berkualitas, dan komitmen terhadap keamanan dan kepuasan pelanggan, OLXTOTO tetap menjadi salah satu pilihan utama bagi para pecinta judi online di Indonesia. Jika Anda mencari pengalaman berjudi yang menyenangkan dan terpercaya, OLXTOTO layak dipertimbangkan.
    • I have been having a problem with minecraft forge. Any version. Everytime I try to launch it it always comes back with error code 1. I have tried launching from curseforge, from the minecraft launcher. I have also tried resetting my computer to see if that would help. It works on my other computer but that one is too old to run it properly. I have tried with and without mods aswell. Fabric works, optifine works, and MultiMC works aswell but i want to use forge. If you can help with this issue please DM on discord my # is Haole_Dawg#6676
    • Add the latest.log (logs-folder) with sites like https://paste.ee/ and paste the link to it here  
    • I have no idea how a UI mod crashed a whole world but HUGE props to you man, just saved me +2 months of progress!  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.