Jump to content

[1.7.10] custom arrow not rendering


Glistre

Recommended Posts

I created a blaster gun.  I used mostly the EntityArrow class to implement IProjectile with the intent of having my blaster gun fire a custom arrow (which I would then be changing to a blaster "bolt").  Problem is the custom arrow or blaster bolt will not render at all.  Clearly when I right click the blaster moves and should shoot something but nothing comes out

 

I have tried this many different ways but cannot get it to fire anything at all. 

 

Blaster

package com.glistre.glistremod.projectiles.blaster;

import com.glistre.glistremod.GlistreMod;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import com.glistre.glistremod.projectiles.blaster.EntityBlasterBolt;

public class Blaster extends Item{
private String texturePath = (GlistreMod.MODID + ":" + "blasterGun_1");
   public Blaster(int par1) {
       super();
   }

   @Override
   public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,
           EntityPlayer par3EntityPlayer) 
   {
       if(!par2World.isRemote)
       {
           par2World.spawnEntityInWorld(new EntityBlasterBolt(par2World, par3EntityPlayer));
       }
       return par1ItemStack;
   }

   @Override   
   @SideOnly(Side.CLIENT)

       public void registerIcons(IIconRegister iconRegister)
       {
           this.itemIcon = iconRegister.registerIcon(texturePath);
       }	   

} 

 

Render class


package com.glistre.glistremod.projectiles.blaster;

import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.init.Items;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import cpw.mods.fml.relauncher.Side;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

import cpw.mods.fml.relauncher.SideOnly;

import com.glistre.glistremod.GlistreMod;
import com.glistre.glistremod.projectiles.blaster.EntityBlasterBolt;

@SideOnly(Side.CLIENT)
public class RendreBlast extends Render
{

private static final ResourceLocation blastTextures = new ResourceLocation("glistremod:/textures/items/wolf_howl.png");
    public void renderBlast(EntityBlasterBolt par1EntityBlast, double par2, double par4, double par6, float par8, float par9)
    {
//        this.loadTexture("/GlistreMod/blast.png");
        GL11.glPushMatrix();
        GL11.glTranslatef((float)par2, (float)par4, (float)par6);
        GL11.glRotatef(par1EntityBlast.prevRotationYaw + (par1EntityBlast.rotationYaw - par1EntityBlast.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(par1EntityBlast.prevRotationPitch + (par1EntityBlast.rotationPitch - par1EntityBlast.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F);
        Tessellator var10 = Tessellator.instance;
        byte var11 = 0;
        float var12 = 0.0F;
        float var13 = 0.5F;
        float var14 = (float)(0 + var11 * 10) / 32.0F;
        float var15 = (float)(5 + var11 * 10) / 32.0F;
        float var16 = 0.0F;
        float var17 = 0.15625F;
        float var18 = (float)(5 + var11 * 10) / 32.0F;
        float var19 = (float)(10 + var11 * 10) / 32.0F;
        float var20 = 0.05625F;
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        float var21 = (float)par1EntityBlast.arrowShake - par9;

        if (var21 > 0.0F)
        {
            float var22 = -MathHelper.sin(var21 * 3.0F) * var21;
            GL11.glRotatef(var22, 0.0F, 0.0F, 1.0F);
        }

        GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
        GL11.glScalef(var20, var20, var20);
        GL11.glTranslatef(-4.0F, 0.0F, 0.0F);
        GL11.glNormal3f(var20, 0.0F, 0.0F);
        var10.startDrawingQuads();
        var10.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)var16, (double)var18);
        var10.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)var17, (double)var18);
        var10.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)var17, (double)var19);
        var10.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)var16, (double)var19);
        var10.draw();
        GL11.glNormal3f(-var20, 0.0F, 0.0F);
        var10.startDrawingQuads();
        var10.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)var16, (double)var18);
        var10.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)var17, (double)var18);
        var10.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)var17, (double)var19);
        var10.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)var16, (double)var19);
        var10.draw();

        for (int var23 = 0; var23 < 4; ++var23)
        {
            GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
            GL11.glNormal3f(0.0F, 0.0F, var20);
            var10.startDrawingQuads();
            var10.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)var12, (double)var14);
            var10.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)var13, (double)var14);
            var10.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)var13, (double)var15);
            var10.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)var12, (double)var15);
            var10.draw();
        }

        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        GL11.glPopMatrix();
    }

    /**
     * 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)
    {
        this.renderBlast((EntityBlasterBolt)par1Entity, par2, par4, par6, par8, par9);
    }


@Override
protected ResourceLocation getEntityTexture(Entity p_110775_1_) {
	// TODO Auto-generated method stub
//		return new ResourceLocation(GlistreMod.MODID +":"+ "wolf_howl.png");
	return this.getEntityTexture((EntityBlasterBolt) p_110775_1_);
}
protected ResourceLocation getEntityTexture(EntityBlasterBolt p_110775_1_){
	return blastTextures;
}
}

 

client proxy:

package com.glistre.glistremod;

import java.awt.Color;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import cpw.mods.fml.client.registry.RenderingRegistry;

import com.glistre.glistremod.CommonProxy;

import com.glistre.glistremod.projectiles.blaster.EntityBlasterBolt;

import com.glistre.glistremod.projectiles.blaster.RendreBlast;

import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.registry.EntityRegistry;


public class ClientProxy extends CommonProxy {


@Override
public void registerRendering(){



        RenderingRegistry.registerEntityRenderingHandler(EntityBlasterBolt.class, new RendreBlast());

   


           

}

}

 

I have put the following in the

main class:


package com.glistre.glistremod;

import java.awt.Color;
import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.projectile.EntityEgg;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.world.World;
import net.minecraft.world.WorldType;

import com.glistre.glistremod.WorldTypeGlistre;
import com.glistre.glistremod.BlockRegistry;

import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.client.event.sound.SoundEvent;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import net.minecraftforge.common.BiomeManager;
import net.minecraftforge.common.BiomeManager.BiomeEntry;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

import com.glistre.glistremod.BiomeRegistry;
import com.glistre.glistremod.MyArmor;
//import com.glistre.glistremod.GlistreArmor;
import com.glistre.glistremod.GlistreDust;
import com.glistre.glistremod.GlistreIngot;
import com.glistre.glistremod.GlistreSword;
import com.glistre.glistremod.CommonProxy;
import com.glistre.glistremod.ClientProxy;
import com.glistre.glistremod.MyItem;
import com.glistre.glistremod.MyPickaxe;
import com.glistre.glistremod.MySword;
import com.glistre.glistremod.MyFood;
import com.glistre.glistremod.MyBlock;
import com.glistre.glistremod.GlistreBiome;
//import com.glistre.glistremod.MyBlockGen;
import com.glistre.glistremod.EntityGlistreWolf;
import com.glistre.glistremod.entities.EntityTobie;
import com.glistre.glistremod.projectiles.MyEntityProjectile;
import com.glistre.glistremod.projectiles.MyProjectile;
import com.glistre.glistremod.projectiles.MyRenderProjectile;
import com.glistre.glistremod.projectiles.blaster.Blaster;
import com.glistre.glistremod.projectiles.blaster.EntityBlasterBolt;
import com.glistre.glistremod.projectiles.blaster.EntityBlasterBoltArrow;
import com.glistre.glistremod.projectiles.blaster.MyProjectile2;
import com.glistre.glistremod.projectiles.blaster.RenderBlast;


/* 	MOD INFO */
@Mod(modid = "GlistreMod", name = "Glistre Mod", version = "2.0")

public class GlistreMod {

public static final String MODID = "GlistreMod";
public static final String NAME = "Glistre Mod";
public static final String VERSION = "2.0";

@Instance("GlistreMod")
public static GlistreMod instance;

/*	PROXY INFO */
@SidedProxy(clientSide = ("com.glistre.glistremod.ClientProxy"), serverSide = ("com.glistre.glistremod.CommonProxy"))
public static CommonProxy proxy;

GlistreEventHandler handler = new GlistreEventHandler();
        public static Item blaster_1;
        public int blaster1ID;
// the ray or blast bolt like an arrow
        public static Item MyProjectile_2;
        public int MyProjectile_2ID;
        
@EventHandler	
public void preInit( FMLPreInitializationEvent event) {



FMLCommonHandler.instance().bus().register(handler);
MinecraftForge.EVENT_BUS.register(handler);

proxy.registerRendering();


        blaster_1 = new Blaster(blaster1ID).setUnlocalizedName("blaster_1").setCreativeTab(GlistreTab_1).setTextureName(MODID + ":"  + "blasterGun_1");
        GameRegistry.registerItem(blaster_1, blaster_1.getUnlocalizedName());       
        MyProjectile_2 = new MyProjectile2(MyProjectile_2ID, "MyProjectile_2").setUnlocalizedName("MyProjectile_2").setCreativeTab(GlistreTab_1);
        EntityRegistry.registerModEntity(EntityBlasterBolt.class, "MyProjectile_2", MyProjectile_2ID, GlistreMod.instance, 128, 1, true);

and for creating a separate arrow or bolt , tried this too:
[code]package com.glistre.glistremod.projectiles.blaster;


import com.glistre.glistremod.GlistreMod;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.Item;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.client.renderer.texture.IIconRegister;

public class MyProjectile2 extends Item {
    
    private String texturePath = (GlistreMod.MODID + ":" + "wolf_howl.png");
    
    public MyProjectile2(int Item, String textureName)
    {
        super();
        this.setUnlocalizedName(textureName);
        this.setTextureName("MyProjectile_2");
        this.setCreativeTab(CreativeTabs.tabMaterials);

    }

@Override   
@SideOnly(Side.CLIENT)

    public void registerIcons(IIconRegister iconRegister)
    {
        this.itemIcon = iconRegister.registerIcon(texturePath);
    }   


}

 

 

Link to comment
Share on other sites

Does  the RendreBlast#renderBlast(...) method get called? Check it.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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