[JAVA] [Forge] Addressing the problem that Render of self-made Entity is not displayed in 1.14.2 and 1.14.3

Development environment

OS IDE Forge JDK Lang
Windows10 1809 17763.593 IntelliJ IDEA 2019 1.14.3-27.0.15 1.8.0_202 Java

Introduction

When I made it compatible with 1.13.2 to 1.14.2, the render of my own Entity was not displayed and I stumbled, so I summarized it. I hope it will be helpful. Entity registration is the same as 1.13.2. → [Forge] How to register your own Entity and Entity Render in 1.13.2 The source code will be explained based on the TorchBowMod of my own mod as before.

Symptoms

The symptom is that the render and entity are linked on the client side as shown below, but they are not displayed.

RenderResist


RenderingRegistry.registerEntityRenderingHandler(EntityTorch.class, RenderTorch::new);

In 1.13.2 this was displayed properly.

Is Entity registered normally?

First of all, I suspected that the Entity registration was not successful. However, since the processing such as collision detection performed by Entity was working normally, it seems that Entity registration is normal.

Cause and remedy

After doing various searches, I found the cause and countermeasures.

Cause

First of all, when registering an Entity with EntityType, until now,

TORCH_ENTITY = EntityType.Builder.<EntityTorch>create(EntityTorch::new, EntityClassification.MISC)

Like, I passed the instance directly to the create method, but in 1.14.2 I had to pass the instance with the newly added setCustomClientFactory instead of this instance.

approach

First, modify the EntityType mentioned earlier.

TORCH_ENTITY = EntityType.Builder.<EntityTorch>create(EntityClassification.MISC)
               .setCustomClientFactory(EntityTorch::new)//Add this line

It is like this. It may be abbreviated in the lambda expression and it may be difficult to understand, but with this alone, an error will occur if the Entity does not have a constructor that meets the expected value of <net.minecraftforge.fml.network.FMLPlayMessages.SpawnEntity, World>. I will. An easy-to-understand lambda expression inside setCustomClientFactory? It looks like this.

.setCustomClientFactory((FMLPlayMessages.SpawnEntity spawnEntity, World world) -> new EntityTorch(spawnEntity,world))

Creating a constructor

public EntityTorch(FMLPlayMessages.SpawnEntity packet, World worldIn) {
    super(TORCH_ENTITY, worldIn);
}

I think you should pass your own Entity Type with super like this. Perhaps. And in addition to adding a constructor to the Entity class, it seems that you need to override createSpawnPacket.

@Override
public IPacket<?> createSpawnPacket() {
    return NetworkHooks.getEntitySpawningPacket(this);
}

It feels like it's overriding like this and returning its own spawn packet. For the time being, the render is displayed like this.

Finally

If you are suffering from the same phenomenon because you have stumbled upon this specification change, please refer to it. Also, if you have any mistakes, please leave an edit request or comment.

Recommended Posts

[Forge] Addressing the problem that Render of self-made Entity is not displayed in 1.14.2 and 1.14.3
When the project is not displayed in eclipse
[Error] The app is not displayed in the production environment
I want to solve the problem that JS is not displayed properly unless reloaded when transitioning with Turbolinks: link_to
About the problem that the image is not displayed after AWS deployment
When I call the file with Class # getResource from the jar file, it becomes Not Found and it is a crappy memorandum
[Forge] Addressing the problem that Render of self-made Entity is not displayed in 1.14.2 and 1.14.3
About the solution to the problem that the log of logback is not output when the web application is stopped
Problem that the attribute of User model becomes nil in ActionMailer
This and that of the implementation of date judgment within the period in Java
Error when the member of Entity class used in SpringWebFlux is final
[Java] java.lang.NoClassDefFoundError: Addressing the problem of falling in org / jsoup / safety / Whitelist
[Cloud9] Yay! You ’re on Rails! Is not displayed in the rails tutorial
Review of "strange Java" and Java knowledge that is often forgotten in Java Bronze
Image is not displayed in production environment
[Java] Where is the implementation class of annotation that exists in Bean Validation?
Is it mainstream not to write the closing tag of <P> tag in Javadoc?
[Java] Something is displayed as "-0.0" in the output
Ebean.update () is not executed in the inherited model.
[Android Studio] About the matter that the design view is not displayed when using TextClock
[Java] The problem that uploaded images are not updated due to the influence of cache
The story that .java is also built in Unity 2018
Now in the third year, the misunderstanding that I noticed is the difference between the equals method and ==
Even if I write the setting of STRICT_QUOTE_ESCAPING in CATALINA_OPTS in tomcat8.5, it is not reflected.