HappleAcks Posted April 20, 2014 Posted April 20, 2014 So if I have a weapon, like a sword... How can I visually scale it up in game so it looks bigger when you hold it? (hitbox doesn't need to change) edit: Scaling is working, but it's at the wrong angle. Is there a way to rotate or flip it? Quote
Godis_apan Posted April 20, 2014 Posted April 20, 2014 Ok I would use a custom item renderer. Make a new class and make it implement the IItemRenderer. Example: package godis_apan.thedecorationpack.medieval.client.render.item; import godis_apan.thedecorationpack.medieval.client.model.ModelOrnateTable; import godis_apan.thedecorationpack.medieval.client.model.ModelTable; import godis_apan.thedecorationpack.medieval.lib.Reference; import godis_apan.thedecorationpack.medieval.lib.Textures; import godis_apan.thedecorationpack.medieval.tileentity.TileEntityTable; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderItem implements IItemRenderer { public RenderItemTable() { } @Override public boolean handleRenderType(ItemStack stack, ItemRenderType renderType) { return true; } @Override public boolean shouldUseRenderHelper(ItemRenderType renderType, ItemStack stack, ItemRendererHelper renderHelper) { return true; } @Override public void renderItem(ItemRenderType renderType, ItemStack stack, Object... data) { } } Thats the basic class. Now in the renderItem() method you want to check the item render type. If it's in the inventory, first/third person or rendered as an entity item on the ground. if (renderType == renderType.EQUIPPED) { GL11.glPushMatrix(); GL11.glScalef(1.5F, 1.5F, 1,5F); GL11.glPopMatrix(); } The you scale it up using the glScalef(). If you scale it alot you will have to translate the item in a correct position (GL11.glTranlatef(x, y, z)). Lastly you want to register the item renderer using: MinecraftForgeClient.registerItemRenderer(myItem, new myRenderer()); I'm suggesting you do that in the client proxy. Quote My mod for futher awesomeness: http://www.minecraftforum.net/topic/1714396-the-decopack-collection-v010-wip-made-a-signature-new-snapshot-1-screenshots-are-up-small-snapshot-1-is-out-for-147/#entry21250399
TheGreyGhost Posted April 21, 2014 Posted April 21, 2014 Hi This link might also be useful http://greyminecraftcoder.blogspot.com.au/2013/09/custom-item-rendering-using.html -TGG Quote
HappleAcks Posted April 21, 2014 Author Posted April 21, 2014 Ok I would use a custom item renderer. Make a new class and make it implement the IItemRenderer. Example: package godis_apan.thedecorationpack.medieval.client.render.item; import godis_apan.thedecorationpack.medieval.client.model.ModelOrnateTable; import godis_apan.thedecorationpack.medieval.client.model.ModelTable; import godis_apan.thedecorationpack.medieval.lib.Reference; import godis_apan.thedecorationpack.medieval.lib.Textures; import godis_apan.thedecorationpack.medieval.tileentity.TileEntityTable; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderItem implements IItemRenderer { public RenderItemTable() { } @Override public boolean handleRenderType(ItemStack stack, ItemRenderType renderType) { return true; } @Override public boolean shouldUseRenderHelper(ItemRenderType renderType, ItemStack stack, ItemRendererHelper renderHelper) { return true; } @Override public void renderItem(ItemRenderType renderType, ItemStack stack, Object... data) { } } Thats the basic class. Now in the renderItem() method you want to check the item render type. If it's in the inventory, first/third person or rendered as an entity item on the ground. if (renderType == renderType.EQUIPPED) { GL11.glPushMatrix(); GL11.glScalef(1.5F, 1.5F, 1,5F); GL11.glPopMatrix(); } The you scale it up using the glScalef(). If you scale it alot you will have to translate the item in a correct position (GL11.glTranlatef(x, y, z)). Lastly you want to register the item renderer using: MinecraftForgeClient.registerItemRenderer(myItem, new myRenderer()); I'm suggesting you do that in the client proxy. When I put in the line: MinecraftForgeClient.registerItemRenderer(HawkshotRifle.class, new RenderRifle()); I am told that registerItemRenderer isn't applicable for the arguments and it gives an error. Hi This link might also be useful http://greyminecraftcoder.blogspot.com.au/2013/09/custom-item-rendering-using.html -TGG Very helpful! But having same problem as above. Quote
coolAlias Posted April 21, 2014 Posted April 21, 2014 That's because it takes an Item, not a Class. Just look at the method arguments and you will see that. Quote http://i.imgur.com/NdrFdld.png[/img]
HappleAcks Posted April 21, 2014 Author Posted April 21, 2014 That's because it takes an Item, not a Class. Just look at the method arguments and you will see that. Ah yes, so no errors and the game loads, but now my weapon appears invisible. My render file: package com.darkMod.item; import net.minecraft.client.renderer.Tessellator; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RifleRender implements IItemRenderer { public void RenderItemTable() { } @Override public boolean handleRenderType(ItemStack stack, ItemRenderType renderType) { return true; } @Override public boolean shouldUseRenderHelper(ItemRenderType renderType, ItemStack stack, ItemRendererHelper renderHelper) { return true; } @Override public void renderItem(ItemRenderType renderType, ItemStack stack, Object... data) { if (renderType == renderType.EQUIPPED) { GL11.glPushMatrix(); GL11.glScalef(1.5F, 1.5F, 1.5F); GL11.glPopMatrix(); } } } My main file related stuff: public static Item HawkshotRifle = new HawkshotRifle(StartingItemID+6, Gun).setUnlocalizedName("hawkshotRifle").setTextureName("eternisles:hawkShot"); private final static RifleRender rifleRender = new RifleRender(); @EventHandler public void load(FMLInitializationEvent event) { addItemsToRegistries(); } private void addItemsToRegistries() { MinecraftForgeClient.registerItemRenderer(HawkshotRifle, new GunRender()); } Quote
coolAlias Posted April 21, 2014 Posted April 21, 2014 Render type EQUIPPED is for 3rd person, and EQUIPPED_FIRST_PERSON is for 1st person (which I'm guessing is where you noticed it's invisible). You need to account for both cases in your render class. If you need a further example, take a look at my RenderBigItem class that I used for my hammers and big swords. Quote http://i.imgur.com/NdrFdld.png[/img]
HappleAcks Posted April 21, 2014 Author Posted April 21, 2014 Render type EQUIPPED is for 3rd person, and EQUIPPED_FIRST_PERSON is for 1st person (which I'm guessing is where you noticed it's invisible). You need to account for both cases in your render class. If you need a further example, take a look at my RenderBigItem class that I used for my hammers and big swords. That makes it appear, however it is at the wrong angle. Is there a way to rotate/flip it? Quote
Godis_apan Posted April 21, 2014 Posted April 21, 2014 GL11.glRotatef(); The params it takes are: GL11.glRotatef(float angle, float x, float y, float z); So if you want to rotate it on the y axis 90 degress the code should be: GL11.glRotatef(90F, 0F, 1.0F, 0F); The most simple way is to play around with it 'til it works! Quote My mod for futher awesomeness: http://www.minecraftforum.net/topic/1714396-the-decopack-collection-v010-wip-made-a-signature-new-snapshot-1-screenshots-are-up-small-snapshot-1-is-out-for-147/#entry21250399
Godis_apan Posted April 21, 2014 Posted April 21, 2014 Ohh and a important thing is the order the GL11 codes comes in, so here is the order: GL11.glPushMatrix(); GL11.glTranslatef(); GL11.glScalef(); GL11.glRotatef(); Here your model goes!!! GL11.glPopMatrix(); Quote My mod for futher awesomeness: http://www.minecraftforum.net/topic/1714396-the-decopack-collection-v010-wip-made-a-signature-new-snapshot-1-screenshots-are-up-small-snapshot-1-is-out-for-147/#entry21250399
coolAlias Posted April 21, 2014 Posted April 21, 2014 That makes it appear, however it is at the wrong angle. Is there a way to rotate/flip it? What Godis_apan said, and also if you setFull3D() in your Item class, it should do all the rotating for you automatically, at least how I've set it up in my render class that I linked earlier. Quote http://i.imgur.com/NdrFdld.png[/img]
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.