Jump to content

Recommended Posts

Posted

I have made a custom 3D ball and wish to render it in my inventory. It is an item that throws like the snowball but in the ItemRenderBall.java class the following switch statement wants to return an entity but when I replace null with (Entity) data[1] I get an out of bounds error.

 

problem code

switch (type) {
	case INVENTORY:
		GL11.glPushMatrix();
		// rotates the item and translates the item
		GL11.glRotatef(0, 0, 0, 1);
		GL11.glRotatef(0, 0, 1, 0);
		GL11.glRotatef(180, 1, 0, 0);
		GL11.glTranslatef(0f, 0f, 0f);
		GL11.glScalef(0.5F, 0.5F, 0.5F);
		Minecraft.getMinecraft().renderEngine.bindTexture(this.itemBallTexture);
		// renders the item
		modelBall.render(null, 0.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 0.0225f);
		GL11.glPopMatrix();
	default:
		break;
	}

 

related mod classes pertaining to this item

 

  Reveal hidden contents
Posted

here is the one that i have do  your renaming and rendirng stuff

 

shooter

package thrizzo.minibots.items;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import thrizzo.minibots.entities.throwable.EntityMiniJBullet;
import thrizzo.minibots.main.MiniBotsMain;

public class ItemBlasterRifle extends Item
{

  public ItemBlasterRifle(int par1)
  {
	 super();

 this.maxStackSize = 1;
  }
  @Override
  public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
  {
  if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(MiniBotsMain.MiniRifleAmmo)){
	  
	  if (!par3EntityPlayer.capabilities.isCreativeMode)
      		{
              par3EntityPlayer.inventory.consumeInventoryItem(MiniBotsMain.MiniRifleAmmo);
      		}
      	par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
      	if (!par2World.isRemote)
      		{
    	  	par2World.spawnEntityInWorld(new EntityMiniJBullet(par2World, par3EntityPlayer));
      		}
      	return par1ItemStack;
  }
 	return par1ItemStack;
  }
}

 

 

shooten entity

 

package thrizzo.minibots.entities.throwable;

import java.util.Random;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

public class EntityMiniJBullet extends EntityThrowable
{    
private Random rand ; 
int speed = 2;
    private double damage = 7.5D ;

   public EntityMiniJBullet(World par1World)
   {
       super(par1World);
   }
   
   
   
   public void setDamage(double par1)
   {
       this.damage = par1;
   }

   public double getDamage()
   {
       return this.damage;
   }

   
   public EntityMiniJBullet(World par1World, EntityLivingBase par2EntityLivingBase)
   {
       super(par1World, par2EntityLivingBase);
       this.motionX*=speed;
       this.motionY*=speed;
       this.motionZ*=speed;
   }
   public EntityMiniJBullet(World par1World, double par2, double par4, double par6)
   {
       super(par1World, par2, par4, par6);
   }
   @Override
   protected void onImpact(MovingObjectPosition movingobjectposition) 
   {
 this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ,(float) 0.25, true);		


    
 this.setDead();

 if (movingobjectposition.entityHit != null)
     {
	 movingobjectposition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float) damage);
     }

   }
   @Override
   protected float getGravityVelocity()
   {
       return 0F;
   }

   
}

 

hope it works for you, it does for me

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.