Jump to content

[1.8.9] Help with rendering EntityThrowable


bignose956
 Share

Recommended Posts

I have a throwable entity that works great and I am satisfied with the onImpact and onUpdate methods, but It still lacks a render. In it's item form it renders fine, but I cannot figure out how to render its entity state. I looked at the RenderSnowball class, but I cannot understand the constructor, which requires three different objects (RenderManager, Item, RenderItem), but got stuck when I came to the constructor for RenderItem and RenderManager because they both require a TextureManager object (which I do not know how to construct). The problem with the TextureManager is that it requires a IResourceManager object in its constructor, and IResourceManagers are interfaces (I'm inexperienced with interfaces).

 

Can anyone explain to me how to render an EntityThrowable or provide me with an accurate 1.8.9  tutorial? 

Edited by bignose956
Link to comment
Share on other sites

16 minutes ago, draganz said:

1.8.9 is no longer supported, and help shall not be given on this forum.

Uhhh, you might wan't double check that. 1.8.9 is still on forge (http://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.8.9.html), and this is the official Forge Forums. Furthermore, I've been receiving help with 1.8.9 this whole week, and you are the only person that has made an unsupported claim about it.

Edited by bignose956
Link to comment
Share on other sites

4 hours ago, bignose956 said:

I have a throwable entity that works great and I am satisfied with the onImpact and onUpdate methods, but It still lacks a render. In it's item form it renders fine, but I cannot figure out how to render its entity state. I looked at the RenderSnowball class, but I cannot understand the constructor, which requires three different objects (RenderManager, Item, RenderItem), but got stuck when I came to the constructor for RenderItem and RenderManager because they both require a TextureManager object (which I do not know how to construct). The problem with the TextureManager is that it requires a IResourceManager object in its constructor, and IResourceManagers are interfaces (I'm inexperienced with interfaces).

 

Can anyone explain to me how to render an EntityThrowable or provide me with an accurate 1.8.9  tutorial? 

 

You don't create the RenderManager or RenderItem instances yourself, you use the instances Minecraft has already created.

 

To register a Render for an Entity class, call RenderingRegistry.registerEntityRenderingHandler(Class<T>, IRenderFactory<? super T>) in preInit. In the IRenderFactory#createRenderFor implementation, create and return the Render instance.

 

You receive the RenderManager instance as an argument of IRenderFactory#createRenderFor and you can get the RenderItem instance using Minecraft#getRenderItem.

 

This advice applies to all versions from 1.8.9 onwards.

 

 

4 hours ago, bignose956 said:

Uhhh, you might wan't double check that. 1.8.9 is still on forge (http://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.8.9.html), and this is the official Forge Forums. Furthermore, I've been receiving help with 1.8.9 this whole week, and you are the only person that has made an unsupported claim about it.

 

1.7.10 and earlier are still available for download, but they're not supported on this forum. I believe 1.8.9 is still supported, but you should really update.

Edited by Choonster

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.

Link to comment
Share on other sites

18 hours ago, Choonster said:

 

You don't create the RenderManager or RenderItem instances yourself, you use the instances Minecraft has already created.

 

To register a Render for an Entity class, call RenderingRegistry.registerEntityRenderingHandler(Class<T>, IRenderFactory<? super T>) in preInit. In the IRenderFactory#createRenderFor implementation, create and return the Render instance.

 

You receive the RenderManager instance as an argument of IRenderFactory#createRenderFor and you can get the RenderItem instance using Minecraft#getRenderItem.

 

This advice applies to all versions from 1.8.9 onwards.

 

 

 

1.7.10 and earlier are still available for download, but they're not supported on this forum. I believe 1.8.9 is still supported, but you should really update.

Ok, I got this far:

public class RenderRock extends Render<EntityRock>{

	public static Factory FACTORY = new Factory();
	
	protected RenderRock(RenderManager renderManager) {
		super(renderManager);
	}

	@Override
	protected ResourceLocation getEntityTexture(EntityRock entity) {
		return new ResourceLocation(Ref.MOD_ID, "textures/entities/projectile/Rock.png");
	}
	
	public static class Factory implements IRenderFactory<EntityRock>{

        @Override
        public Render<? super EntityRock> createRenderFor(RenderManager manager) {
            return new RenderRock(manager);
        }
    }
}

and the preInit:

@EventHandler
	public void preInit(FMLPreInitializationEvent event)
	{
		
		MinecraftForge.EVENT_BUS.register(handler);
		
		theseBlocks.Init();
		theseBlocks.register();
		theseItems.Init();
		theseItems.register();
		
		RenderingRegistry.registerEntityRenderingHandler(EntityRock.class, RenderRock.FACTORY);
		
	}

But the textures are still not rendering... What am I doing wrong? All my texture images are 16x16 or a multiple. (They render fine as items...)

 

Also, I really despise 1.9 and higher, and could't image "updating" to them, >_<  but thank you for the advice =)

Edited by bignose956
Link to comment
Share on other sites

5 hours ago, bignose956 said:

Also, I really despise 1.9 and higher, and could't image "updating" to them, >_<

Why? There are no reasons to stay on the outdated versions. Especially now, with the community actively wanting to set 1.12 as the "mainstream" version. There are modpacks for it already for crying out loud, we don't even have a stable forge yet...

No one is going to use your mod if it is that outdated.

 

5 hours ago, bignose956 said:

What am I doing wrong?

Well, you've registered your renderer. Are you maybe going to do something in there? You know, by default an implementation of Render is not going to do anything. You need to provide it with code that it will use to render something. You currently have only defined the textures used for rendering, but you are not telling the game how to render your entity.

Maybe you could use an implementation of RenderSnowball that renders your rock instead of the snowball? Please explain what you want your entity to look like.

Link to comment
Share on other sites

57 minutes ago, V0idWa1k3r said:

Why? There are no reasons to stay on the outdated versions. Especially now, with the community actively wanting to set 1.12 as the "mainstream" version. There are modpacks for it already for crying out loud, we don't even have a stable forge yet...

No one is going to use your mod if it is that outdated.


I wouldn't use the term "outdated", because a lot of negative features were added post 1.8. Minecraft used to be a noob friendly sandbox game, and was transformed into a complicated RPG with too many options. I specifically hate this because it is forcing players like myself to update, when indeed we dislike the "new content". I don't like any of the combat 'improvements', the elytra thing is nothing like Minecraft (especially if you're from the 1.3 era). I believe that the updates should have been kept simple, and none should have changed the game fundamentals. If players want this, they can always build or download a mod. But now we are basically being forced to use mods we are not interested in.

 

57 minutes ago, V0idWa1k3r said:

Well, you've registered your renderer. Are you maybe going to do something in there? You know, by default an implementation of Render is not going to do anything. You need to provide it with code that it will use to render something. You currently have only defined the textures used for rendering, but you are not telling the game how to render your entity.

Maybe you could use an implementation of RenderSnowball that renders your rock instead of the snowball? Please explain what you want your entity to look like.

I want my entity to be the same as a snowball as in its render is the same as it's item form, and it is "2D" from all angles. I tried this: 

public void doRender(EntityRock entity, double x, double y, double z, float entityYaw, float partialTicks)
    {
        GlStateManager.pushMatrix();
        GlStateManager.translate((float)x, (float)y, (float)z);
        GlStateManager.enableRescaleNormal();
        GlStateManager.scale(0.5F, 0.5F, 0.5F);
        GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
        this.bindTexture(getEntityTexture(entity));
        this.theRenderItem.renderItem(this.getItemStack(entity), ItemCameraTransforms.TransformType.GROUND);
        GlStateManager.disableRescaleNormal();
        GlStateManager.popMatrix();
        super.doRender(entity, x, y, z, entityYaw, partialTicks);
    }

but I got a nullpointer at 

this.theRenderItem.renderItem(this.getItemStack(entity), ItemCameraTransforms.TransformType.GROUND);

 

Edited by bignose956
Link to comment
Share on other sites

1 minute ago, bignose956 said:

I want my entity to be the same as a snowball as in its render is the same as it's item form, and it is "2D" from all angles.

It seems that you can simply return a new instance of RenderSnowball then. Look at it's constructor. You already have your RenderManager in your factory, the Item is your item(the rock) and you can obtain an instance of RenderItem at Minecraft::getRenderItem

Link to comment
Share on other sites

28 minutes ago, V0idWa1k3r said:

It seems that you can simply return a new instance of RenderSnowball then. Look at it's constructor. You already have your RenderManager in your factory, the Item is your item(the rock) and you can obtain an instance of RenderItem at Minecraft::getRenderItem

I didn't understand that at all ???

Link to comment
Share on other sites

In your render factory (the RenderRock.Factory subclass), in it's 

6 hours ago, bignose956 said:

createRenderFor

method return a new instance of RenderSnowball(new RenderSnowball). It's constructor takes 3 parameters.

1. a RenderManager. You already have one(it is the only parameter of the createRenderFor method)

2. an Item. That is the item you want the texture of to render. In your case it is your Rock item if you have one. I do not know where do you keep your item references so I can't give you a code snippet to use.

3. a RenderItem. You can obtain one using Minecraft.getMinecraft().getRenderItem().

If you want your item to render as a snowball but with a different texture you might aswell use snowball's renderer instead of writing your own.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
On 6/13/2017 at 3:25 AM, V0idWa1k3r said:

In your render factory (the RenderRock.Factory subclass), in it's 

method return a new instance of RenderSnowball(new RenderSnowball). It's constructor takes 3 parameters.

1. a RenderManager. You already have one(it is the only parameter of the createRenderFor method)

2. an Item. That is the item you want the texture of to render. In your case it is your Rock item if you have one. I do not know where do you keep your item references so I can't give you a code snippet to use.

3. a RenderItem. You can obtain one using Minecraft.getMinecraft().getRenderItem().

If you want your item to render as a snowball but with a different texture you might aswell use snowball's renderer instead of writing your own.

Ohh!! I got it! Thanks!

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

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I am using a modified MeleeAttackGoal to make an entity pick a random button, go to it and press it. But after a while it just stops and stares at the current button target. I found out that it's just staring at it because it's too far away to press it.  And its's not moving because the current path in the mob navigation is "done". If I move it further away it recalculates a non weird path and fixes itself. If I push it towards the button so it can press it, it sets the target to null, so it once again calculates a new path and fixes itself. What is causing the path to be "done"? And how can I fix this? This is the tick method in the custom goal class: public void tick() { if (mob.buttonTarget != null) { float x = mob.buttonTarget.getX(); float y = mob.buttonTarget.getY(); float z = mob.buttonTarget.getZ(); float hx = x + 0.5f; float hy = y + 0.5f; float hz = z + 0.5f; mob.getLookControl().setLookAt(hx, hy, hz, 30.0F, 30.0F); double distSqr = mob.distanceToSqr(hx, hy, hz); ticksUntilNextPathRecalculation = Math.max(ticksUntilNextPathRecalculation - 1, 0); if ((followingTargetEvenIfNotSeen || hasLineOfSight(mob, mob.buttonTarget)) && ticksUntilNextPathRecalculation <= 0 && ((pathedTargetX == 0.0D && pathedTargetY == 0.0D && pathedTargetZ == 0.0D) || mob.buttonTarget.distSqr(new Vec3i(pathedTargetX, pathedTargetY, pathedTargetZ)) >= 1.0D || mob.getRandom().nextFloat() < 0.05F)) { pathedTargetX = hx; pathedTargetY = hy; pathedTargetZ = hz; ticksUntilNextPathRecalculation = 4 + mob.getRandom().nextInt(7); if (distSqr > 1024.0D) ticksUntilNextPathRecalculation += 10; else if (distSqr > 256.0D) ticksUntilNextPathRecalculation += 5; Path newPath = mob.getNavigation().createPath(mob.buttonTarget, 0); if (newPath != null && !newPath.canReach()) { mob.buttonTarget = null; return; } if (!mob.getNavigation().moveTo(newPath, speedModifier)) ticksUntilNextPathRecalculation += 15; ticksUntilNextPathRecalculation = adjustedTickDelay(ticksUntilNextPathRecalculation); } ticksUntilNextAttack = Math.max(getTicksUntilNextAttack() - 1, 0); checkAndPerformAttack(mob.buttonTarget, distSqr); } }  
    • As of Forge version 44.1.5 and above, Minecraft has started crashing whenever I played it with the Create mod. Without any mods, it loads normally, but when I put in a mod, like MrCrayfish's furniture mod for example, it fails to read the mod properly. Basically I press play and it loads. When the launcher closes, it opens back up again with an Exit Code 1 error, stating that the game crashed due to an unexpected error. Here's my latest.log for more information. https://pastebin.com/pUPBjpbr  
    • The files are harmed by system flaws and glitches. Additionally, the installation procedure might cause files to be lost. The game is so terminated, and an exit code 1 error is displayed. Therefore, attempt a game reinstall.
    • Hello there!  I'm hosting a Minecraft Tekxit PI server on Minecraft 1.12.2 on my computer and I have a little issue. Everything was going great until one day my light in my house went down while a friend was inside the server. The server crashed and when I came back 2 chunks swapped but everything seemed normal. Fastforward in time my friend who was inside the server tried to come back in it but everti-me he tries to join he cannot do it and there is a crash in the server logs. If any other friend tries to join they can, but, that friend that was inside the server when that occurred cannot join. I tried rebooting, rebooting my modem, deleting his player data to start over and nothing works. I'm leaving the crash logs here. Thank you!!! ----------------------------------------------- CRASH LOGS   [10:27:10] [Netty Server IO #1/INFO]: Transforming class 'gu', alias 'net.minecraft.network.NettyCompressionDecoder' [10:27:10] [Netty Server IO #1/INFO]: Scanning method 'decode(Lio/netty/channel/ChannelHandlerContext;Lio/netty/buffer/ByteBuf;Ljava/util/List;)V' [10:27:10] [Netty Server IO #1/INFO]: Patching constant (java.lang.Integer) 2097152 [10:27:10] [Netty Server IO #1/INFO]: Patching constant (java.lang.Integer) 2097152 [10:27:10] [Netty Server IO #1/INFO]: [com.creativemd.creativecore.transformer.CreativeTransformer:transform:49]: [littletiles] Patched net.minecraft.network.NettyCompressionDecoder ... [10:27:13] [Server thread/ERROR]: HandshakeMessageHandler exception java.lang.OutOfMemoryError: Java heap space     at java.util.ArrayList.<init>(Unknown Source) ~[?:1.8.0_361]     at com.google.common.collect.Lists.newArrayListWithCapacity(Lists.java:190) ~[minecraft_server.1.12.2.jar:?]     at net.minecraft.nbt.NBTTagList.read(NBTTagList.java:58) ~[ge.class:?]     at net.minecraft.nbt.NBTTagCompound.readNBT(NBTTagCompound.java:497) ~[fy.class:?]     at net.minecraft.nbt.NBTTagCompound.read(NBTTagCompound.java:58) ~[fy.class:?]     at net.minecraft.nbt.NBTTagCompound.readNBT(NBTTagCompound.java:497) ~[fy.class:?]     at net.minecraft.nbt.NBTTagCompound.read(NBTTagCompound.java:58) ~[fy.class:?]     at net.minecraft.nbt.CompressedStreamTools.read(CompressedStreamTools.java:133) ~[gi.class:?]     at net.minecraft.nbt.CompressedStreamTools.read(CompressedStreamTools.java:88) ~[gi.class:?]     at net.minecraft.nbt.CompressedStreamTools.readCompressed(CompressedStreamTools.java:31) ~[gi.class:?]     at net.minecraft.world.storage.SaveHandler.getPlayerNBT(SaveHandler.java:278) ~[bfb.class:?]     at net.minecraft.server.management.PlayerList.getPlayerNBT(PlayerList.java:340) ~[pl.class:?]     at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.serverInitiateHandshake(NetworkDispatcher.java:220) ~[NetworkDispatcher.class:?]     at net.minecraftforge.fml.common.network.handshake.FMLHandshakeServerState$1.accept(FMLHandshakeServerState.java:49) ~[FMLHandshakeServerState$1.class:?]     at net.minecraftforge.fml.common.network.handshake.HandshakeMessageHandler.userEventTriggered(HandshakeMessageHandler.java:65) ~[HandshakeMessageHandler.class:?]     at io.netty.channel.AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext.java:329) ~[minecraft_server.1.12.2.jar:?]     at io.netty.channel.AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext.java:315) ~[minecraft_server.1.12.2.jar:?]     at io.netty.channel.AbstractChannelHandlerContext.fireUserEventTriggered(AbstractChannelHandlerContext.java:307) ~[minecraft_server.1.12.2.jar:?]     at io.netty.channel.ChannelInboundHandlerAdapter.userEventTriggered(ChannelInboundHandlerAdapter.java:108) ~[minecraft_server.1.12.2.jar:?]     at io.netty.channel.AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext.java:329) ~[minecraft_server.1.12.2.jar:?]     at io.netty.channel.AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext.java:315) ~[minecraft_server.1.12.2.jar:?]     at io.netty.channel.AbstractChannelHandlerContext.fireUserEventTriggered(AbstractChannelHandlerContext.java:307) ~[minecraft_server.1.12.2.jar:?]     at io.netty.channel.ChannelInboundHandlerAdapter.userEventTriggered(ChannelInboundHandlerAdapter.java:108) ~[minecraft_server.1.12.2.jar:?]     at io.netty.channel.AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext.java:329) ~[minecraft_server.1.12.2.jar:?]     at io.netty.channel.AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext.java:315) ~[minecraft_server.1.12.2.jar:?]     at io.netty.channel.AbstractChannelHandlerContext.fireUserEventTriggered(AbstractChannelHandlerContext.java:307) ~[minecraft_server.1.12.2.jar:?]     at io.netty.channel.DefaultChannelPipeline$HeadContext.userEventTriggered(DefaultChannelPipeline.java:1352) ~[minecraft_server.1.12.2.jar:?]     at io.netty.channel.AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext.java:329) ~[minecraft_server.1.12.2.jar:?]     at io.netty.channel.AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext.java:315) ~[minecraft_server.1.12.2.jar:?]     at io.netty.channel.DefaultChannelPipeline.fireUserEventTriggered(DefaultChannelPipeline.java:920) ~[minecraft_server.1.12.2.jar:?]     at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.insertIntoChannel(NetworkDispatcher.java:183) ~[NetworkDispatcher.class:?]     at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.serverToClientHandshake(NetworkDispatcher.java:154) ~[NetworkDispatcher.class:?]
    • (Mod name is Custom Npcs)
  • Topics

×
×
  • Create New...

Important Information

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