paradoxbomb Posted February 15, 2016 Posted February 15, 2016 I'm not really sure where to go for questions like this... I have a custom projectile that I've made, and it works, but it's currently invisible as I don't know how to actually tell Minecraft what to render. I tried Googling, but apparently everyone already knows how or something. Is there a tutorial somewhere I'm missing? Quote <signature></signature>
Ernio Posted February 15, 2016 Posted February 15, 2016 I STRONGLY recommend looking into vanilla renderers. 1. Google Entity rendering. What you are looking for is "how to register renderer". 2. Copy code from RenderSnowball - it's a goood start. 3. Have fun with examples vanilla gives. Points of interest: Minecraft.getMinecraft().getRenderManager(); RenderingRegistry.registerEntityRenderingHandler(MyEntity.class, new RenderMyEntity()); Rendering goes in init(). Quote 1.7.10 is no longer supported by forge, you are on your own.
coolAlias Posted February 15, 2016 Posted February 15, 2016 There is nothing special about rendering a projectile entity vs. a regular entity - all entities are handled the same way: 1. Create your Entity class 2. Register your Entity class via the EntityRegistry 3. Register a Render class for your Entity (you can use vanilla Render classes or create your own) If your projectile has an Item associated with it (i.e. ammunition), then I suggest you start off by using the vanilla RenderSnowball class - don't even copy it, just use it directly until your projectile is rendering. This will help to ensure the rest of your code is correct before you start messing around with a Render class. Also, 1.8.9 introduces the IRenderFactory which is a factory method that allows you to register your Entity renderers during PreInit (it postpones the actual registration until later when the Minecraft render manager has actually been initialized). This is now the preferred method, though I'm not sure what was wrong with simply registering renderers during the init phase. Quote http://i.imgur.com/NdrFdld.png[/img]
paradoxbomb Posted February 16, 2016 Author Posted February 16, 2016 All right, now I'm running into the problem that RenderSnowball 's constructor takes three arguments, the last two of which are obfuscated for some reason: public RenderSnowball(RenderManager renderManagerIn, Item p_i46137_2_, RenderItem p_i46137_3_) { super(renderManagerIn); this.field_177084_a = p_i46137_2_; this.field_177083_e = p_i46137_3_; } Also when trying to add my projectile to my EntityRenderer class, it says that the current method is deprecated and that the version that will be around in 1.9 needs a renderFactory. What the heck is that and how do I pass it correctly? Quote <signature></signature>
coolAlias Posted February 16, 2016 Posted February 16, 2016 The obfuscated names simply mean no one has gotten around to submitting 'translations' for them to MCP yet, but it's pretty obvious what they are. You can get the RenderManager and RenderItem directly from the Minecraft class, whether you use the IRenderFactory or the deprecated version. // Old way: RenderManager manager = Minecraft.getMinecraft().getRenderManager(); RenderItem itemRender = Minecraft.getMinecraft().getRenderItem(); RenderingRegistry.registerEntityRenderingHandler(YourProjectileEntity.class, new RenderSnowball(manager, YourModItems.projectileItem, itemRender)); For the new way, you actually have to create a class that implements IRenderFactory and fill in whatever methods it has, then register your renderer passing a new instance of your factory instead of the Minecraft RenderManager and RenderItem. Quote http://i.imgur.com/NdrFdld.png[/img]
paradoxbomb Posted February 16, 2016 Author Posted February 16, 2016 They might be obvious to a vet like you, but I have no idea. Help a newbie out? Quote <signature></signature>
coolAlias Posted February 16, 2016 Posted February 16, 2016 They might be obvious to a vet like you, but I have no idea. Help a newbie out? I haven't updated any of my mods to 1.8.9 yet, so I can't give you the exact syntax for the IRenderFactory, but as long as you have a basic grasp of Java, it should be pretty straightforward, e.g.: public class MyFactory implements IRenderFactory { // whatever fields you need, e.g. Item to render public MyFactory(/* whatever args you need, e.g. Item item*/) { // initialize any class fields you made } // implement whatever methods it requires } // now when you register your renderers, it would be something like this: RenderingRegistry.registerEntityRenderingHandler(YourProjectileEntity.class, new MyFactory(MyModItems.projectileItem)); See? Not so hard. If that's too complicated, you can still use the deprecated registration method - just make sure to call it during the init phase rather than pre-init, whereas the new way is done during pre-init. Quote http://i.imgur.com/NdrFdld.png[/img]
paradoxbomb Posted February 16, 2016 Author Posted February 16, 2016 That code snippet will definitely be invaluable once I actually get the thing working, but I was referring to the obfuscated fields in the RenderSnowball.java file. Quote <signature></signature>
Choonster Posted February 16, 2016 Posted February 16, 2016 That code snippet will definitely be invaluable once I actually get the thing working, but I was referring to the obfuscated fields in the RenderSnowball.java file. The Item argument is the item to render the entity as and the RenderItem argument is Minecraft's RenderItem instance (coolAlias showed how to get this in post #4). Quote 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.
Recommended Posts
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.