Jump to content

[1.15.1] How to make a custom entity?


DragonITA

Recommended Posts

Hi, sorry for this late reply! I dont know exactly how to Java syntax work if a error was found. Lua Syntax will stop the script (here it is the .class or the .java) if a error was found then the code dont continue and i muss rerun the script in eclipse. This take some time. Ok, why i say this? I say this then i have a Problem with my custom BlockItem. I want first resolve this Problem and then show the code.

P.S.: I need a little bit of time to refind the code.

Edit: Resolved

Edited by DragonITA
P.S.

New in Modding? == Still learning!

Link to comment
Share on other sites

3 hours ago, DragonITA said:

Hi, sorry for this late reply! I dont know exactly how to Java syntax work if a error was found. Lua Syntax will stop the script (here it is the .class or the .java) if a error was found then the code dont continue and i muss rerun the script in eclipse. This take some time. Ok, why i say this? I say this then i have a Problem with my custom BlockItem. I want first resolve this Problem and then show the code.

P.S.: I need a little bit of time to refind the code.

Java is a static language. It has to compile before running. There must be no syntax errors.

However, it sounds like you are struggling with basic Java syntax. Please learn Java before making a mod, as not knowing Java will cause unnecessary confusions.

  • Like 1

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

Thanks, i am trying to learn Java. I know a little bit the Heritage of the Java syntax. Here is on how i actualy make my entity (i have tried to find the Init Folder in the Vanilla Code to see hoz i should register my entities, but i cant find it. So I tried to watch a video of HarryTalks with version 1.14.4 to go further. But I get an error, have tried to solve it with my current knowledge, but I can't get it right.) Here is my current Code:

 

package mod.dragonita.fantasymod.entities;

import mod.dragonita.fantasymod.init.FantasyModEntities;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.goal.LookAtGoal;
import net.minecraft.entity.ai.goal.LookRandomlyGoal;
import net.minecraft.entity.ai.goal.PanicGoal;
import net.minecraft.entity.ai.goal.WaterAvoidingRandomWalkingGoal;
import net.minecraft.entity.passive.horse.HorseEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;

public class UnicornEntity extends HorseEntity{
	
	@SuppressWarnings("unchecked")
	public UnicornEntity(EntityType<? extends HorseEntity> type, World worldIn) {
		super((EntityType<? extends HorseEntity>) FantasyModEntities.UNICORN_ENTITY, worldIn);
	}

	protected void registerGoals()
	{
		this.goalSelector.addGoal(1, new PanicGoal(this, 1.2D));
		this.goalSelector.addGoal(6, new WaterAvoidingRandomWalkingGoal(this, 0.7D));
		this.goalSelector.addGoal(7, new LookAtGoal(this, PlayerEntity.class, 6.0F));
		this.goalSelector.addGoal(8, new LookRandomlyGoal(this));
	}
	
	protected void registerAttributes()
	{
		super.registerAttributes();
		this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(10.0d);
		this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(5.0d);
	}
}

 

package mod.dragonita.fantasymod.init;

import mod.dragonita.fantasymod.Main;
import mod.dragonita.fantasymod.entities.UnicornEntity;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
import net.minecraft.item.SpawnEggItem;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.biome.Biome.SpawnListEntry;
import net.minecraftforge.event.RegistryEvent;

public class FantasyModEntities {
	
	public static EntityType<?> UNICORN_ENTITY = EntityType.Builder.create(UnicornEntity::new, EntityClassification.CREATURE).build(Main.MODID + ":unicorn_entity").setRegistryName(new ResourceLocation(Main.MODID, "unicorn_entity"));
	
	public static void registerEntitySpawnEggs(final RegistryEvent.Register<Item> event)
	{
		event.getRegistry().registerAll
		(
			ModItems.UNICORN_ENTITY_EGG = registerEntitySpawnEgg(UNICORN_ENTITY, 0xf0f0f0, 0xdf51f5, "unicorn_entity_egg")	
		);
	}
	
	public static void registerEntityWorldSpawns()
	{
		registerEntityWorldSpawn(UNICORN_ENTITY, Biomes.PLAINS, Biomes.JUNGLE, Biomes.BEACH);
	}
	
	public static Item registerEntitySpawnEgg(EntityType<?> type, int color1, int color2, String name)
	{
		SpawnEggItem item = new SpawnEggItem(type, color1, color2, new Item.Properties().group(ModItemGroups.RAINBOW_MOD_GROUP));
		item.setRegistryName(new ResourceLocation(Main.MODID, name));
		return item;
	}
	
	public static void registerEntityWorldSpawn(EntityType<?> entity, Biome... biomes)
	{
		for(Biome biome : biomes)
		{
			if(biome != null)
			{
				biome.getSpawns(entity.getClassification()).add(new SpawnListEntry(entity, 20, 1, 10));
			}
		}
	}
}

 

 

package mod.dragonita.fantasymod.client.renders;

import mod.dragonita.fantasymod.client.models.UnicornEntityModel;
import mod.dragonita.fantasymod.entities.UnicornEntity;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.entity.LivingRenderer;
import net.minecraft.entity.passive.horse.AbstractHorseEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.registry.IRenderFactory;

@OnlyIn(Dist.CLIENT)
public class UnicornEntityRender extends LivingRenderer<AbstractHorseEntity, UnicornEntityModel>
{
	public UnicornEntityRender(EntityRendererManager manager)
	{
		super(manager, new UnicornEntityModel(0f), 0f);
	}

	public static final ResourceLocation unicorn = new ResourceLocation("fantasymod:textures/entity/unicorn_entity.png");
	
	public static class RenderFactory implements IRenderFactory<UnicornEntity>
	{

		@Override
		public EntityRenderer<? super UnicornEntity> createRenderFor(EntityRendererManager manager)
		{
			return new UnicornEntityRender(manager);
		}
		
	}

	@Override
	public ResourceLocation getEntityTexture(AbstractHorseEntity entity) {
		return unicorn;
	}
}

 

package mod.dragonita.fantasymod.client.models;

import net.minecraft.client.renderer.entity.model.HorseModel;
import net.minecraft.entity.passive.horse.AbstractHorseEntity;

public class UnicornEntityModel extends HorseModel<AbstractHorseEntity>
{

	public UnicornEntityModel(float p_i51065_1_) {
		super(p_i51065_1_);
	}

}

 

Im have troubles here:

package mod.dragonita.fantasymod.client.renders;

import mod.dragonita.fantasymod.entities.UnicornEntity;
import mod.dragonita.fantasymod.init.FantasyModEntities;
import mod.dragonita.fantasymod.init.ModEntities;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.passive.horse.HorseEntity;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.registry.RenderingRegistry;

@OnlyIn(Dist.CLIENT)
public class FantasyRenderRegistry
{
	@SuppressWarnings("unchecked")
	public static void registryEntityRenders()
	{
		RenderingRegistry.registerEntityRenderingHandler((EntityType<? extends HorseEntity>) FantasyModEntities.UNICORN_ENTITY, new UnicornEntityRender.RenderFactory()); //Here i have my errors message
	}
}

I am getting the following error message: 

The method registerEntityRenderingHandler(EntityType<T>, IRenderFactory<? super T>) in the type RenderingRegistry is not applicable for the arguments (EntityType<capture#2-of ? extends HorseEntity>, UnicornEntityRender.RenderFactory)

I already say thank you for all your help.

New in Modding? == Still learning!

Link to comment
Share on other sites

4 hours ago, diesieben07 said:

Do not create registry entries in a static initializer. Use the DeferredRegister class.

I am new in Java and Modding. What is a registry entrie?

4 hours ago, diesieben07 said:

Do not use @OnlyIn.

Why?

4 hours ago, diesieben07 said:

The error message says that the arguments you are trying to pass to registerEntityRenderingHandler are not valid. Check the method parameters and their types and make sure your arguments match.

I arleady made this, but i am new and i dont find what i made wrong. Its want a entity type and i have arleady write my entity type, but it have still continue to send me this error message. I tried, but it dont work.

New in Modding? == Still learning!

Link to comment
Share on other sites

6 hours ago, DragonITA said:

I am new in Java and Modding. What is a registry entrie?

Any implementation of IForgeRegistry (blocks, items, etc). These should be created during the appropiate registry event.

 

6 hours ago, DragonITA said:

I arleady made this, but i am new and i dont find what i made wrong. Its want a entity type and i have arleady write my entity type, but it have still continue to send me this error message. I tried, but it dont work.

This is basic Java syntax. If you are struggling with this then you need to learn Java before making a mod. This is not a Java forum.

Edited by DavidM
  • Like 1

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

On 1/5/2020 at 1:50 AM, DavidM said:

This is basic Java syntax. If you are struggling with this then you need to learn Java before making a mod. This is not a Java forum.

Ok, thanks. What is a EntityType? Is this my Entity or something else? Auf jedenfalls arbeite ich gerade um dieses Problem lösen können.

 

On 1/4/2020 at 2:38 PM, diesieben07 said:

Use the DeferredRegister class.

Should i replace the RenderingRegistry with the DeferredRegister?

 

Ok, I know that I'm annoying you with my questions, and I also tried to look at some vanilla code, but all I need is this: In which folder is the Entity RenderRegistry? I'm looking for a solution to my problem right now, and as it is written in the tips from @DavidM: The best way to learn is to look at the vanilla code. So I've been thinking and want to look at a classic code. I'm just now noticing how many things I have to work on, so I want to finish this topic first and then improve myself, because it must be really annoying to try to help someone who doesn't know anything.

 

 

Thanks for reading it.

Edited by DragonITA
I switched Tom with DavidM, no idea why I wrote Tom.

New in Modding? == Still learning!

Link to comment
Share on other sites

7 minutes ago, diesieben07 said:

EntityType is just that: A type of entity, such as "creeper" or "zombie".

It simply is the Type of my Entity, my Entity in others word. Can i use my Entity like a EntityType?

Edit: I was so stupid, the solution was before my eyes for the whole time. I already made an EntityType, just had to import it.

Edited by DragonITA
I found a solution to my first problem.

New in Modding? == Still learning!

Link to comment
Share on other sites

@diesieben07, i'm sorry, I was just checking to make sure. 

Ok, so if I understood and read well then I should implement the IForgeRegistryEntry in a class. The (hopefully last) question: Where should I implement it, in which class? I don't want to take any risk, but if I have read it then I have to implement it in my entity class. Am I right?

New in Modding? == Still learning!

Link to comment
Share on other sites

On 1/4/2020 at 2:38 PM, diesieben07 said:

The error message says that the arguments you are trying to pass to registerEntityRenderingHandler are not valid. Check the method parameters and their types and make sure your arguments match.

I resolved it.

New in Modding? == Still learning!

Link to comment
Share on other sites

33 minutes ago, diesieben07 said:

You would know this if you had read the (already linked) documentation:

On 1/5/2020 at 1:54 PM, diesieben07 said:

I read it, only dont have see the difference between client physical side and client logical side.

this is what my IDE shows me (Tried to look at a vanilla code):

@net.minecraftforge.api.distmarker.OnlyIn(value=net.minecraftforge.api.distmarker.Dist.CLIENT)

I know it's exactly the same. But I don't understand that, even with the link you've already given. I just find it hard to understand that, and except for these four differences I don't understand at all. Why do you say I can't do it this way, but the vanilla code does exactly that? Could you explain it to me (And yes, I repeat, I read the link and still don't understand it)?

New in Modding? == Still learning!

Link to comment
Share on other sites

 

2 minutes ago, diesieben07 said:

However the code is not identical of course, some things (like GUIs or world rendering) only exist on the client. These things are marked by forge using @OnlyIn to signify "I only found this in distribution X".

(Similarly some things may only exist in the dedicated server distribution, but is going to be a much, much shorter list that is largely irrelevant for modding).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

21 minutes ago, diesieben07 said:

A more modern name for physical side is "distribution".

 

This is the physical client (client distribution):
image.png.0820c9f02aa62ed957151d303e846c1c.png

When you start a single-player world it starts a logical client and a logical server (the integrated server). The distribution remains client, even for the integrated server. You don't suddenly have a dedicated server running.

When you connect to a server it starts a logical client.

 

This is the physical server (server distribution):

image.png.83f15c573a349cbf20abd8690109f69b.png

It only contains one logical side: The server. The distribution is always server.

 

Well, it definitely exists.

 

@OnlyIn is a forge thing. Vanilla does not have this.

During setup, forge merges the minecraft client jar and the server jar together (the two distributions, see the images above if you don't know the difference) to create one codebase.

However the code is not identical of course, some things (like GUIs or world rendering) only exist on the client. These things are marked by forge using @OnlyIn to signify "I only found this in distribution X".

Wow, thanks for that answer. Now I understand everything except for one point: Why can't I use @OnlyIn and what should I replace it with (the docs is really outdated soon and I don't know what to use now. Strange, when I pressed ctrl + spacebar in the IDE, then normal white comes up with a whole bunch of variables/functions I can use, but I haven't seen any FMLEnvironment.Dist)? If it is, then how should I use it? Usually my IDE tells me, but I don't see anything.

New in Modding? == Still learning!

Link to comment
Share on other sites

  • 3 weeks later...
On 1/8/2020 at 4:45 PM, DragonITA said:

I resolved it.

Can you please show your solution or tell me the name of the official java-class, that calls "registerEntityRenderingHandler" to register entity renderers?

I don´t know how to find this file, if i don´t know it´s name..

Edited by Drachenbauer
  • Like 1
Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • ladangtoto situs resmi ladangtoto situs terpercaya 2024   Temukan situs resmi dan terpercaya untuk tahun 2024 di LadangToto! Dengan layanan terbaik dan keamanan yang terjamin, LadangToto adalah pilihan utama untuk penggemar judi online. Daftar sekarang untuk mengakses berbagai jenis permainan taruhan, termasuk togel, kasino, dan banyak lagi. Jelajahi sensasi taruhan yang tak terlupakan dan raih kesempatan besar untuk meraih kemenangan di tahun ini dengan LadangToto!" [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]] [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]]
    • WINNING303 DAFTAR SITUS JUDI SLOT RESMI TERPERCAYA 2024 Temukan situs judi slot resmi dan terpercaya untuk tahun 2024 di Winning303! Daftar sekarang untuk mengakses pengalaman berjudi slot yang aman dan terjamin. Dengan layanan terbaik dan reputasi yang kokoh, Winning303 adalah pilihan terbaik bagi para penggemar judi slot. Jelajahi berbagai pilihan permainan dan raih kesempatan besar untuk meraih kemenangan di tahun ini dengan Winning303 [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]] [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]]
    • SLOT PULSA TANPA POTONGAN : SLOT PULSA 5000 VIA INDOSAT IM3 TANPA POTONGAN - SLOT PULSA XL TELKOMSEL TANPA POTONGAN  KLIK DISINI DAFTAR DISINI SLOT VVIP << KLIK DISINI DAFTAR DISINI SLOT VVIP << KLIK DISINI DAFTAR DISINI SLOT VVIP << KLIK DISINI DAFTAR DISINI SLOT VVIP << SITUS SLOT GACOR 88 MAXWIN X500 HARI INI TERBAIK DAN TERPERCAYA GAMPANG MENANG Dunia Game gacor terus bertambah besar seiring berjalannya waktu, dan sudah tentu dunia itu terus berkembang serta merta bersamaan dengan berkembangnya SLOT GACOR sebagai website number #1 yang pernah ada dan tidak pernah mengecewakan sekalipun. Dengan banyaknya member yang sudah mempercayakan untuk terus menghasilkan uang bersama dengan SLOT GACOR pastinya mereka sudah percaya untuk bermain Game online bersama dengan kami dengan banyaknya testimoni yang sudah membuktikan betapa seringnya member mendapatkan jackpot besar yang bisa mencapai ratusan juta rupiah. Best online Game website that give you more money everyday, itu lah slogan yang tepat untuk bermain bersama SLOT GACOR yang sudah pasti menang setiap harinya dan bisa menjadikan bandar ini sebagai patokan untuk mendapatkan penghasilan tambahan yang efisien dan juga sesuatu hal yang fix setiap hari nya. Kami juga mendapatkan julukan sebagai Number #1 website bocor yang berarti terus memberikan member uang asli dan jackpot setiap hari nya, tidak lupa bocor itu juga bisa diartikan dalam bentuk berbagi promosi untuk para official member yang terus setia bermain bersama dengan kami. Berbagai provider Game terus bertambah banyak setiap harinya dan terus melakukan support untuk membuat para official member terus bisa menang dan terus maxwin dalam bentuk apapun maka itu langsung untuk feel free to try yourself, play with SLOT GACOR now or never !
    • BRI4D adalah pilihan tepat bagi Anda yang menginginkan pengalaman bermain slot dengan RTP tinggi dan transaksi yang akurat melalui Bank BRI. Berikut adalah beberapa alasan mengapa Anda harus memilih BRI4D: Tingkat Pengembalian (RTP) Tertinggi Kami bangga menjadi salah satu agen situs slot dengan RTP tertinggi, mencapai 99%! Ini berarti Anda memiliki peluang lebih besar untuk meraih kemenangan dalam setiap putaran permainan. Transaksi Melalui Bank BRI yang Akurat Proses deposit dan penarikan dana di BRI4D cepat, mudah, dan akurat. Kami menyediakan layanan transaksi melalui Bank BRI untuk kenyamanan Anda. Dengan begitu, Anda dapat melakukan transaksi dengan lancar dan tanpa khawatir. Beragam Pilihan Permainan BRI4D menyajikan koleksi permainan slot yang beragam dan menarik dari berbagai provider terkemuka. Mulai dari tema klasik hingga yang paling modern, Anda akan menemukan banyak pilihan permainan yang sesuai dengan selera dan preferensi Anda.  
    • SPARTA88 adalah pilihan tepat bagi Anda yang menginginkan agen situs slot terbaik dengan RTP tinggi dan transaksi yang mudah melalui Bank BNI. Berikut adalah beberapa alasan mengapa Anda harus memilih SPARTA88: Tingkat Pengembalian (RTP) Tinggi Kami bangga menjadi salah satu agen situs slot dengan RTP tertinggi, mencapai 98%! Ini berarti Anda memiliki peluang lebih besar untuk meraih kemenangan dalam setiap putaran permainan. Beragam Pilihan Permainan SPARTA88 menyajikan koleksi permainan slot yang beragam dan menarik dari berbagai provider terkemuka. Mulai dari tema klasik hingga yang paling modern, Anda akan menemukan banyak pilihan permainan yang sesuai dengan selera dan preferensi Anda. Kemudahan Bertransaksi Melalui Bank BNI Proses deposit dan penarikan dana di SPARTA88 cepat, mudah, dan aman. Kami menyediakan layanan transaksi melalui Bank BNI untuk kenyamanan Anda. Dengan begitu, Anda dapat melakukan transaksi dengan lancar tanpa perlu khawatir.
  • Topics

×
×
  • Create New...

Important Information

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