Jump to content

Recommended Posts

Posted

My mod adds in the ability to reanimate dead entities into a spectral version of themselves. I would like this function to work with all living entities from vanilla to any mod, so would it be possible to use the original entity's model and texture?

Posted

If you store an instance of the dead

Entity

in your

Entity

, you can use

RenderManager#getEntityRenderObject

to get its

Render

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

The same way Minecraft saves your entity to NBT: call

Entity#writeToNBT

and store the compound tag in your own entity's compound tag.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Call the dead entity

Render

's methods from the corresponding methods of your

Render

, e.g. override

Render#doRender

to fetch the dead entity's

Render

and call

doRender

on it, passing the dead entity as an argument.

 

It may be difficult to create a "spectral" effect works with any entity, since you can't know how that entity will be rendered. I don't know anything about OpenGL, so I can't help you there.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

You should be able to use

EntityList#createEntityFromNBT

to create an

Entity

from a compound tag that was previously written to by

Entity#writeToNBT

. The

Entity#isDead

field isn't persisted. It's also public, so you can just set it to

false

when the entity is first reanimated.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

When rendering the entity it appears that the entity is null but I am not sure why.

 

[10:15:48] [Client thread/FATAL]: Reported exception thrown!
net.minecraft.util.ReportedException: Rendering entity in world
at net.minecraft.client.renderer.entity.RenderManager.doRenderEntity(RenderManager.java:428) ~[RenderManager.class:?]
at net.minecraft.client.renderer.entity.RenderManager.renderEntityStatic(RenderManager.java:337) ~[RenderManager.class:?]
at net.minecraft.client.renderer.entity.RenderManager.renderEntitySimple(RenderManager.java:304) ~[RenderManager.class:?]
at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:672) ~[RenderGlobal.class:?]
at net.minecraft.client.renderer.EntityRenderer.renderWorldPass(EntityRenderer.java:1368) ~[EntityRenderer.class:?]
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1282) ~[EntityRenderer.class:?]
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1110) ~[EntityRenderer.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1107) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:380) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:116) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_65]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_65]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:26) [start/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_65]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:?]
Caused by: java.lang.NullPointerException
at net.minecraft.client.renderer.entity.RenderManager.getEntityRenderObject(RenderManager.java:237) ~[RenderManager.class:?]
at soulmagic.entity.EntitySpectral.getRender(EntitySpectral.java:74) ~[EntitySpectral.class:?]
at soulmagic.client.renderer.entity.SpectralRenderFactory$SpectralRender.doRender(SpectralRenderFactory.java:27) ~[spectralRenderFactory$SpectralRender.class:?]
at soulmagic.client.renderer.entity.SpectralRenderFactory$SpectralRender.doRender(SpectralRenderFactory.java:17) ~[spectralRenderFactory$SpectralRender.class:?]
at net.minecraft.client.renderer.entity.RenderManager.doRenderEntity(RenderManager.java:380) ~[RenderManager.class:?]
... 26 more

 

Render:

https://github.com/LogicTechCorp/SoulMagic/blob/master/src/main/java/soulmagic/client/renderer/entity/SpectralRenderFactory.java

 

Soul:

https://github.com/LogicTechCorp/SoulMagic/blob/master/src/main/java/soulmagic/entity/item/EntitySoul.java

 

Spectral:

https://github.com/LogicTechCorp/SoulMagic/blob/master/src/main/java/soulmagic/entity/EntitySpectral.java

 

Posted

You should probably call the super methods in your overrides of

Entity#readEntityFromNBT

and

Entity#writeEntityToNBT

, but I don't think that's the cause of the issue here.

 

I suspect the issue is that the server has a reference to the original entity when the spectral entity is first spawned and when it's read from NBT, but the client doesn't know anything about it. If you want to sync data from the server to the client when an entity is spawned in the world, you can implement

IEntityAdditionalSpawnData

in your

Entity

class. I suggest you use this to send the NBT serialised entity from the server to the client, then deserialise it back into an entity on the client side.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Am I doing it correctly?

 

    @Override
    public void writeSpawnData(ByteBuf buffer)
    {
        NBTTagCompound entityTag = this.entity.serializeNBT();
        ByteBufUtils.writeTag(buffer, entityTag);
    }

    @Override
    public void readSpawnData(ByteBuf additionalData)
    {
        NBTTagCompound entityTag = ByteBufUtils.readTag(additionalData);
        this.entity.deserializeNBT(entityTag);
    }

Posted

You're writing the NBT correctly, but

this.entity

will be

null

on the client, so you can't call

Entity#deserializeNBT

on it. You need to use

EntityList.createEntityFromNBT

instead, which creates the entity and then reads it from NBT.

 

I just realised that

Entity#writeToNBT

doesn't save the entity's string ID, which is needed to recreate it from NBT. Use

Entity#serializeNBT

instead, which does save the ID.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

It works but now I have a new problem.

 

java.lang.ClassCastException: soulmagic.entity.EntitySpectral cannot be cast to net.minecraft.entity.passive.EntityChicken
at net.minecraft.client.renderer.entity.RenderChicken.handleRotationFloat(RenderChicken.java:10) ~[RenderChicken.class:?]
at net.minecraft.client.renderer.entity.RendererLivingEntity.doRender(RendererLivingEntity.java:140) [RendererLivingEntity.class:?]
at net.minecraft.client.renderer.entity.RenderLiving.doRender(RenderLiving.java:54) [RenderLiving.class:?]
at net.minecraft.client.renderer.entity.RenderLiving.doRender(RenderLiving.java:16) [RenderLiving.class:?]
at soulmagic.client.renderer.entity.SpectralRenderFactory$SpectralRender.doRender(SpectralRenderFactory.java:27) [spectralRenderFactory$SpectralRender.class:?]
at soulmagic.client.renderer.entity.SpectralRenderFactory$SpectralRender.doRender(SpectralRenderFactory.java:17) [spectralRenderFactory$SpectralRender.class:?]
at net.minecraft.client.renderer.entity.RenderManager.doRenderEntity(RenderManager.java:380) [RenderManager.class:?]
at net.minecraft.client.renderer.entity.RenderManager.renderEntityStatic(RenderManager.java:337) [RenderManager.class:?]
at net.minecraft.client.renderer.entity.RenderManager.renderEntitySimple(RenderManager.java:304) [RenderManager.class:?]
at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:672) [RenderGlobal.class:?]
at net.minecraft.client.renderer.EntityRenderer.renderWorldPass(EntityRenderer.java:1368) [EntityRenderer.class:?]
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1282) [EntityRenderer.class:?]
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1110) [EntityRenderer.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1107) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:380) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:116) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_65]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_65]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:26) [start/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_65]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:?]

Posted

Think about it, you are trying to render "entity" as "otherEntity".

 

Logically - you need your renderer to use fields of "otherEntity".

 

For example:

@Override
        public void doRender(EntitySpectral entity, double x, double y, double z, float entityYaw, float partialTicks)
        {
            entity.getRender(renderManager).doRender(entity.otherEntity, x, y, z, entityYaw, partialTicks); // entity.otherEntity, you should also use "otherEntity" values everywhere else.
        }

1.7.10 is no longer supported by forge, you are on your own.

Posted

Sounds like dead AI to me... You're going to need to write your entity wrapper to either take over logic or feed updates to the contained entity...

I think its my java of the variables.

Posted

Call the super method from

EntitySpectral#onLivingUpdate

. If you override a method (especially one that updates stuff), you'll usually want to call the super method. You have a lot of overridden methods not calling their super methods.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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



×
×
  • Create New...

Important Information

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