Jump to content

Recommended Posts

Posted
On 12/27/2019 at 2:03 PM, DragonITA said:

i can‘t find any tutorial.

The best tutorial is vanilla code. Take a look at a simple mob's Entity, Renderer, and Model classes. I'm just now dabbling with it, but from what I can tell registering mobs is the same as 1.14.

Posted (edited)

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!

Posted
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.

 

 

Posted

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!

Posted
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!

Posted (edited)
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.

 

 

Posted (edited)
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!

Posted (edited)
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!

Posted

@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!

Posted
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!

Posted
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!

Posted

 

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.

Posted
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!

Posted

Like this:???

@EventBusSubscriber(modid = Main.MODID, bus = EventBusSubscriber.Bus.MOD, value = FMLEnvironment.Dist)
public class Something(){
//Do something
}

 

New in Modding? == Still learning!

Posted
@EventBusSubscriber(modid = Main.MODID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class Something(){
//Do something
}

 

New in Modding? == Still learning!

  • 3 weeks later...
Posted (edited)
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

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

    • that happens every time I enter a new dimension.
    • This is the last line before the crash: [ebwizardry]: Synchronising spell emitters for PixelTraveler But I have no idea what this means
    • What in particular? I barely used that mod this time around, and it's never been a problem in the past.
    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } } my entire project:https://github.com/kevin051606/DERP-Mod/tree/Derp-1.0-1.20
  • Topics

×
×
  • Create New...

Important Information

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