Jump to content

Recommended Posts

Posted

Hi,

I just have a quick question.

 

Is it possible to render your own model to use as a projectile? The reason i'm asking is because i want to throw a pizza box, but it would look better if i make a rectangle in techne. Is there a way to do this?

 

If not, do you have any ideas on how to make it look good?

 

thanks,

-Pandassaurus

Posted

Hi,

so i have the model class, but i don't know where to insert in into the code, and what else i would have to do.

 

this is my code for the render class (i copied it from the render snowball class)

 

 

@SideOnly(Side.CLIENT)
public class RenderFulminatedMercury extends Render {
    private Item field_94151_a;
    private int field_94150_f;

    public RenderFulminatedMercury(Item par1Item, int par2) {
        this.field_94151_a = par1Item;
        this.field_94150_f = par2;
    }

    public RenderFulminatedMercury(Item par1Item) {
        this(par1Item, 0);
    }

    /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) {
        IIcon iicon = this.field_94151_a.getIconFromDamage(this.field_94150_f);

        if (iicon != null) {
            GL11.glPushMatrix();
            GL11.glTranslatef((float) par2, (float) par4, (float) par6);
            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
            GL11.glScalef(0.5F, 0.5F, 0.5F);
            this.bindEntityTexture(par1Entity);
            Tessellator tessellator = Tessellator.instance;

            if (iicon == ItemPotion.func_94589_d("bottle_splash")) {
                int i = PotionHelper.func_77915_a(((EntityPotion) par1Entity).getPotionDamage(), false);
                float f2 = (float) (i >> 16 & 255) / 255.0F;
                float f3 = (float) (i >> 8 & 255) / 255.0F;
                float f4 = (float) (i & 255) / 255.0F;
                GL11.glColor3f(f2, f3, f4);
                GL11.glPushMatrix();
                this.func_77026_a(tessellator, ItemPotion.func_94589_d("overlay"));
                GL11.glPopMatrix();
                GL11.glColor3f(1.0F, 1.0F, 1.0F);
            }

            this.func_77026_a(tessellator, iicon);
            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
            GL11.glPopMatrix();
        }
    }

    /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
    protected ResourceLocation getEntityTexture(Entity par1Entity) {
        return TextureMap.locationItemsTexture;
    }


    private void func_77026_a(Tessellator par1Tessellator, IIcon par2Icon) {
        float f = par2Icon.getMinU();
        float f1 = par2Icon.getMaxU();
        float f2 = par2Icon.getMinV();
        float f3 = par2Icon.getMaxV();
        float f4 = 1.0F;
        float f5 = 0.5F;
        float f6 = 0.25F;
        GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
        par1Tessellator.startDrawingQuads();
        par1Tessellator.setNormal(0.0F, 1.0F, 0.0F);
        par1Tessellator.addVertexWithUV((double) (0.0F - f5), (double) (0.0F - f6), 0.0D, (double) f, (double) f3);
        par1Tessellator.addVertexWithUV((double) (f4 - f5), (double) (0.0F - f6), 0.0D, (double) f1, (double) f3);
        par1Tessellator.addVertexWithUV((double) (f4 - f5), (double) (f4 - f6), 0.0D, (double) f1, (double) f2);
        par1Tessellator.addVertexWithUV((double) (0.0F - f5), (double) (f4 - f6), 0.0D, (double) f, (double) f2);
        par1Tessellator.draw();
    }
}

 

 

 

 

thanks a lot, and any help is appreciated!

-Pandassaurus

Posted

Have you ever used a model for an entity before? Add a field for your model in the render class and make sure to call the model's render methods when appropriate.

 

While it's not the best example, you can see one here. It's 1.6.4, but everything to do with the model is exactly the same in 1.7.2.

 

Every model / render is different, though, so the Rotate/Translate etc. methods you will need to tweak yourself until it looks right.

Posted

Hi,

i tried, but alas, it didn't work.

 

this is what i did:

 


public class RenderPizzaProjectile extends Render {
    @SideOnly(Side.CLIENT)
    protected ModelBase model;
    private Item field_94151_a;
    private int field_94150_f;

    public RenderPizzaProjectile(Item par1Item, int par2) {
        this.field_94151_a = par1Item;
        this.field_94150_f = par2;
        model = new ModelPizzaProjectile();
    }

    public RenderPizzaProjectile(Item par1Item) {
        this(par1Item, 0);
        model = new ModelPizzaProjectile();
    }


    @Override
    protected ResourceLocation getEntityTexture(Entity pizza) {
        return new ResourceLocation("breakingbad", "textures/items/PizzaProjectileModel.png");
    }

    public void doRender(Entity pizza, double x, double y, double z, float yaw, float partialTick) {
        renderEntityModel(pizza, x, y, z, yaw, partialTick);
    }

    public void renderEntityModel(Entity pizza, double x, double y, double z, float yaw, float partialTick) {
        GL11.glPushMatrix();
        this.bindTexture(getEntityTexture(pizza));
        GL11.glTranslatef((float) x, (float) y, (float) z);
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        model.render(pizza, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0);
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        GL11.glPopMatrix();
    }
}

 

 

i think the end part there is wrong. idk. When i right click, it's invisible. Is it because of the render class or because of something else?

 

Just in case, here are the other classes:

 

Entity:

 


public class EntityPizzaProjectile extends EntityThrowable {
    public EntityPizzaProjectile(World par1World) {
        super(par1World);
    }

    public EntityPizzaProjectile(World par1World, EntityLivingBase par2EntityLivingBase) {
        super(par1World, par2EntityLivingBase);
    }

    public EntityPizzaProjectile(World par1World, double par2, double par4, double par6) {
        super(par1World, par2, par4, par6);
    }


    protected void onImpact(MovingObjectPosition par1MovingObjectPosition) {
        if (par1MovingObjectPosition.entityHit != null) {
            float damage = 1;

            par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float) damage);
        }

        for (int i = 0; i < 8; ++i) {
            this.worldObj.spawnParticle("crit", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
        }

        worldObj.setBlock((int) this.posX, (int) this.posY, (int) this.posZ, BreakingBad.Pizza_);

        if (!this.worldObj.isRemote) {
            this.setDead();
        }
    }
}

 

 

Projectile:

 

*/
public class PizzaProjectile extends Item {

    public PizzaProjectile() {
        this.setCreativeTab(BreakingBad.BreakingBadTab_);
        this.setUnlocalizedName("Pizza Projectile");
        this.setTextureName("breakingbad:PizzaProjectile");
    }
    public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) {
        if (!player.capabilities.isCreativeMode) {
            --itemstack.stackSize;
        }

        world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!world.isRemote) {
            world.spawnEntityInWorld(new EntityPizzaProjectile(world, player));
        }

        return itemstack;
    }
}

 

 

My client proxy line:

RenderingRegistry.registerEntityRenderingHandler(EntityPizzaProjectile.class, new RenderPizzaProjectile(BreakingBad.PizzaProjectile_));

 

 

Thanks a lot for all the help!

-Pandassaurus

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.