Jump to content

Recommended Posts

Posted

Hello everyone,

 

I've been trying to render a weapon with a custom mob that I created, but I can't seem to figure out what bit of code I need to put in the render***.java.  I want to render just a stone sword in the right hand of the mob.  Here is the render***.java class:

 

 

package timescape.render;

 

import java.awt.geom.Arc2D.Float;

 

import org.lwjgl.opengl.GL11;

 

import timescape.ModelNutcracker;

import timescape.entity.EntityNutcracker;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.model.ModelEnderman;

import net.minecraft.client.renderer.entity.RenderLiving;

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLiving;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

 

@SideOnly(Side.CLIENT)

public class RenderNutcracker extends RenderLiving

{

        public RenderNutcracker(ModelNutcracker ModelNutcracker_Test, float f)

        {

                super(new ModelNutcracker(), 0.5F);

        }

        public RenderNutcracker(ModelBase par1ModelBase, float par2)

        {

                super(par1ModelBase, par2);

        }

        public void RenderNutcracker(EntityNutcracker par1EntityNutcracker, double par2, double par4, double par6, float par8, float par9)

        {

                super.doRenderLiving(par1EntityNutcracker, par2, par4, par6, par8, par9);

        }

        public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9)

        {

                this.RenderNutcracker((EntityNutcracker)par1EntityLiving, par2, par4, par6, par8, par9);

        }

        public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)

        {

                this.RenderNutcracker((EntityNutcracker)par1Entity, par2, par4, par6, par8, par9);

        }

}

 

 

 

If you need anything else to help me, then let me know.  Any help is appreciated.

 

Greenman

Posted

I have no idea, but the solution offered may end up helping me with a tile entity that needs to do something similar.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Does nobody else have this problem other than me and Draco?

 

Admittedly I want to render a sword on a TileEntity...

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

It's a matter of special rendering code in either case. You'll need to play around with glScale() and glRotate() and glTranslate() until you find values that fit.

 

My question is:

What is it that I am rendering?  I don't want to go into techne and try and figure out how to build the boxes so that it looks like a sword.

 

Which means there's got to be some kind of model for items around somewhere already.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

It's a matter of special rendering code in either case. You'll need to play around with glScale() and glRotate() and glTranslate() until you find values that fit.

 

My question is:

What is it that I am rendering?  I don't want to go into techne and try and figure out how to build the boxes so that it looks like a sword.

 

Which means there's got to be some kind of model for items around somewhere already.

 

You render items with ItemRenderer.renderItemIn2D

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted
You render items with ItemRenderer.renderItemIn2D

 

Ah ha!  Sweet, thanks.

Hadn't delved into the code that vanilla has to render items yet other than "hey, didn't I dup a mob that could do it?" and looking at that mob's render code (with no luck).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

You render items with ItemRenderer.renderItemIn2D

 

Ah ha!  Sweet, thanks.

Hadn't delved into the code that vanilla has to render items yet other than "hey, didn't I dup a mob that could do it?" and looking at that mob's render code (with no luck).

 

Well, I had to use this for a custom item renderer with glowing parts of textures (if you wanna see what I mean:

)

There's also some code in the RenderBiped or RenderLiving (can't remember which one) which deals with holding items by entities.

If you want to do it easy on your Entity, I suggest you override the getHeldItem method in your entity class and return an ItemStack, containing the item which should be held.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted
Well, I had to use this for a custom item renderer with glowing parts of textures (if you wanna see what I mean:
)

 

Neat!

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

You render items with ItemRenderer.renderItemIn2D

 

Ah ha!  Sweet, thanks.

Hadn't delved into the code that vanilla has to render items yet other than "hey, didn't I dup a mob that could do it?" and looking at that mob's render code (with no luck).

 

Well, I had to use this for a custom item renderer with glowing parts of textures (if you wanna see what I mean:

)

There's also some code in the RenderBiped or RenderLiving (can't remember which one) which deals with holding items by entities.

If you want to do it easy on your Entity, I suggest you override the getHeldItem method in your entity class and return an ItemStack, containing the item which should be held.

 

Is this what you mean about overriding the geHeldItem?

 

 

public int getHeldItem;

        {

        ItemStack itemstack = this.getHeldItem(Item.swordStone);

       

        }

 

Posted

You render items with ItemRenderer.renderItemIn2D

 

Ah ha!  Sweet, thanks.

Hadn't delved into the code that vanilla has to render items yet other than "hey, didn't I dup a mob that could do it?" and looking at that mob's render code (with no luck).

 

Well, I had to use this for a custom item renderer with glowing parts of textures (if you wanna see what I mean:

)

There's also some code in the RenderBiped or RenderLiving (can't remember which one) which deals with holding items by entities.

If you want to do it easy on your Entity, I suggest you override the getHeldItem method in your entity class and return an ItemStack, containing the item which should be held.

 

Is this what you mean about overriding the geHeldItem?

 

 

public int getHeldItem;

        {

        ItemStack itemstack = this.getHeldItem(Item.swordStone);

       

        }

 

 

no... It's a method. Its return value is an ItemStack, so you have to return an ItemStack, containing the item which should be held...

	@Override
public ItemStack getHeldItem() {
	return new ItemStack(ItemInstance);
}

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted
You render items with ItemRenderer.renderItemIn2D

no... It's a method. Its return value is an ItemStack, so you have to return an ItemStack, containing the item which should be held...

	@Override
public ItemStack getHeldItem() {
	return new ItemStack(ItemInstance);
}

 

Hmm, I did that, but I had no change in-game.  I also looked at the renderbiped.java and this is the only thing I could find that would be helpful in the render***.java

 

 

protected void renderEquippedItems(EntityLiving par1EntityLiving, float par2)

        {

            float f1 = 1.0F;

            GL11.glColor3f(f1, f1, f1);

            super.renderEquippedItems(par1EntityLiving, par2);

            ItemStack itemstack = par1EntityLiving.getHeldItem();

            ItemStack itemstack1 = par1EntityLiving.getCurrentArmor(3);

            float f2;

        }

 

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • You would have better results asking a more specific question. What have you done? What exactly do you need help with? Please also read the FAQ regarding posting logs.
    • Hi, this is my second post with the same content as no one answered this and it's been a long time since I made the last post, I want to make a client-only mod, everything is ok, but when I use shaders, none of the textures rendered in RenderLevelStageEvent nor the crow entity model are rendered, I want them to be visible, because it's a horror themed mod I've already tried it with different shaders, but it didn't work with any of them and I really want to add support for shaders Here is how i render the crow model in the CrowEntityRenderer<CrowEntity>, by the time i use this method, i know is not the right method but i don't think this is the cause of the problem, the renderType i'm using is entityCutout @Override public void render(CrowEntity p_entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { super.render(p_entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); ClientEventHandler.getClient().crow.renderToBuffer(poseStack, bufferSource.getBuffer(ClientEventHandler.getClient().crow .renderType(TEXTURE)), packedLight, OverlayTexture.NO_OVERLAY, Utils.rgb(255, 255, 255)); } Here renderLevelStage @Override public void renderWorld(RenderLevelStageEvent e) { horrorEvents.draw(e); } Here is how i render every event public void draw(RenderLevelStageEvent e) { for (HorrorEvent event : currentHorrorEvents) { event.tick(e.getPartialTick()); event.draw(e); } } Here is how i render the crow model on the event @Override public void draw(RenderLevelStageEvent e) { if(e.getStage() == RenderLevelStageEvent.Stage.AFTER_ENTITIES) { float arcProgress = getArcProgress(0.25f); int alpha = (int) Mth.lerp(arcProgress, 0, 255); int packedLight = LevelRenderer.getLightColor(Minecraft.getInstance().level, blockPos); VertexConsumer builder = ClientEventHandler.bufferSource.getBuffer(crow); Crow<CreepyBirdHorrorEvent> model = ClientEventHandler .getClient().crow; model.setupAnim(this); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, packedLight, OverlayTexture.NO_OVERLAY, alpha); builder = ClientEventHandler.bufferSource.getBuffer(eyes); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, 15728880, OverlayTexture.NO_OVERLAY, alpha); } } How i render the model public static void renderModelInWorld(Model model, Vector3f pos, Vector3f offset, Camera camera, PoseStack matrix, VertexConsumer builder, int light, int overlay, int alpha) { matrix.pushPose(); Vec3 cameraPos = camera.getPosition(); double finalX = pos.x - cameraPos.x + offset.x; double finalY = pos.y - cameraPos.y + offset.y; double finalZ = pos.z - cameraPos.z + offset.z; matrix.pushPose(); matrix.translate(finalX, finalY, finalZ); matrix.mulPose(Axis.XP.rotationDegrees(180f)); model.renderToBuffer(matrix, builder, light, overlay, Utils .rgba(255, 255, 255, alpha)); matrix.popPose(); matrix.popPose(); } Thanks in advance
    • Same issue - I have no idea
    • I am trying to develop a modpack for me and my friends to use on our server. Does anyone know how to develop a modpack for a server or could they help take a look at my modpack to potentially help at all?
    • un server de armas realista.  
  • Topics

×
×
  • Create New...

Important Information

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