Jump to content

Recommended Posts

Posted

good days

i have little experience whith entityes in general but

long ago i doo a pair of custom arrows the only thing was this two has been left whitout a texture

today i retake the work

for wath i read i just need the code of the arrow and the code for the render but idont know how to register this render or where

 

 

flechaMercenaria.java

package mercenarymod.items.arcos;

import mercenarymod.Mercenary;
import mercenarymod.utilidades.nbtMercenaria;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Items;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class flechaMercenaria extends Item
{
           
    public flechaMercenaria()
    {
    	String name = "flechaMercenaria";
    	setUnlocalizedName(Mercenary.MODID + "_" + name);
    	GameRegistry.registerItem(this, name);
    	setCreativeTab(Mercenary.herramientas);
        this.maxStackSize = 64;
        this.setMaxDamage(0);
        
    }
    
  //######################################################################################3	
  @Override
  public ModelResourceLocation getModel(ItemStack flechas, EntityPlayer playerIn, int useRemaining){
  	
  	ModelResourceLocation modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/flechaMercenaria00", "inventory");	 
  	
  	
  	/*	
    switch(flechas.stackSize){
    case 1:   modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/flechaMercenaria00", "inventory");break;
    case 2:   modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/flechaMercenaria01", "inventory");break;
    default : modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/flechaMercenaria02", "inventory");break;
                             }
    */
  	
  	return modelresourcelocation;	
  
  }
  //####################################################################################3		 

    @Override
    public ItemStack onItemRightClick(ItemStack flechas, World worldIn, EntityPlayer playerIn)
    {
       
        return flechas;
    }

    public int getItemEnchantability()
    {
        return 1;
    }
}

 

renderFlechaMercenaria

package mercenarymod.items.render;

import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import org.lwjgl.opengl.GL11;

@SideOnly(Side.CLIENT)
public class renderFlechaMercenaria extends Render
{
    private static final ResourceLocation arrowTextures = new ResourceLocation("modmercenario:textures/entity/arrow.png");
    private static final String __OBFID = "CL_00000978";

    public renderFlechaMercenaria(RenderManager p_i46193_1_)
    {
        super(p_i46193_1_);
    }

    public void doRender(EntityArrow p_180551_1_, double p_180551_2_, double p_180551_4_, double p_180551_6_, float p_180551_8_, float p_180551_9_)
    {
        this.bindEntityTexture(p_180551_1_);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.pushMatrix();
        GlStateManager.translate((float)p_180551_2_, (float)p_180551_4_, (float)p_180551_6_);
        GlStateManager.rotate(p_180551_1_.prevRotationYaw + (p_180551_1_.rotationYaw - p_180551_1_.prevRotationYaw) * p_180551_9_ - 90.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(p_180551_1_.prevRotationPitch + (p_180551_1_.rotationPitch - p_180551_1_.prevRotationPitch) * p_180551_9_, 0.0F, 0.0F, 1.0F);
        Tessellator tessellator = Tessellator.getInstance();
        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
        byte b0 = 0;
        float f2 = 0.0F;
        float f3 = 0.5F;
        float f4 = (float)(0 + b0 * 10) / 32.0F;
        float f5 = (float)(5 + b0 * 10) / 32.0F;
        float f6 = 0.0F;
        float f7 = 0.15625F;
        float f8 = (float)(5 + b0 * 10) / 32.0F;
        float f9 = (float)(10 + b0 * 10) / 32.0F;
        float f10 = 0.05625F;
        GlStateManager.enableRescaleNormal();
        float f11 = (float)p_180551_1_.arrowShake - p_180551_9_;

        if (f11 > 0.0F)
        {
            float f12 = -MathHelper.sin(f11 * 3.0F) * f11;
            GlStateManager.rotate(f12, 0.0F, 0.0F, 1.0F);
        }

        GlStateManager.rotate(45.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.scale(f10, f10, f10);
        GlStateManager.translate(-4.0F, 0.0F, 0.0F);
        GL11.glNormal3f(f10, 0.0F, 0.0F);
        worldrenderer.startDrawingQuads();
        worldrenderer.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f8);
        worldrenderer.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f8);
        worldrenderer.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f9);
        worldrenderer.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f9);
        tessellator.draw();
        GL11.glNormal3f(-f10, 0.0F, 0.0F);
        worldrenderer.startDrawingQuads();
        worldrenderer.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f8);
        worldrenderer.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f8);
        worldrenderer.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f9);
        worldrenderer.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f9);
        tessellator.draw();

        for (int i = 0; i < 4; ++i)
        {
            GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
            GL11.glNormal3f(0.0F, 0.0F, f10);
            worldrenderer.startDrawingQuads();
            worldrenderer.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)f2, (double)f4);
            worldrenderer.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)f3, (double)f4);
            worldrenderer.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)f3, (double)f5);
            worldrenderer.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)f2, (double)f5);
            tessellator.draw();
        }

        GlStateManager.disableRescaleNormal();
        GlStateManager.popMatrix();
        super.doRender(p_180551_1_, p_180551_2_, p_180551_4_, p_180551_6_, p_180551_8_, p_180551_9_);
    }

    protected ResourceLocation getEntityTexture(EntityArrow p_180550_1_)
    {
        return arrowTextures;
    }

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

    /**
     * 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 func_76986_a(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doe
     */
    public void doRender(Entity entity, double x, double y, double z, float p_76986_8_, float partialTicks)
    {
        this.doRender((EntityArrow)entity, x, y, z, p_76986_8_, partialTicks);
    }
}

 

im basing this code in some scatter info about 1.7 im trying to register this in the postInit from my ClientProxy but lloks like its something misiong insede the parentesys from renderFlechaMercenaria("It askme for something here and itis not a 'null' ")

 

ClientProxy.java

        //@Mod.EventHandler
        //public void postInit(FMLPostInitializationEvent event) {
        public void postInit() {	
        		
        	System.out.println("########\n\n\n ClientProxy postInit()");
        	MinecraftForge.EVENT_BUS.register(new NotificationMercenaria(Minecraft.getMinecraft(), null));
        	
        	RenderingRegistry.registerEntityRenderingHandler(flechaMercenaria.class, new renderFlechaMercenaria(null));
        	
        }

 

 

 

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.